View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015708CMakeCMakepublic2015-08-22 10:492016-01-04 11:52
Reporterovz 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformMac OS XOSOS Version
Product VersionCMake 3.2.3 
Target VersionFixed in Version 
Summary0015708: Use CMAKE_MACOSX_RPATH to link a library outside build tree
DescriptionThis issue is Mac OS X specific. I would like to link a library lib_xxx that sits outside my build tree at some arbitrary location. It will be at the same location in all systems. By default CMake would add the dependency as follows

@executable_path/libwupienginemac.dylib
I would like to know how to change @executable_path to either

1) Absolute path to the library. I see, for example the following in otool output

/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
2) @rpath. I could then manage the location of lib_xxx using RPATH. I prefer this option.

From the documentation and forums it looks like CMAKE_MACOSX_RPATH should solve the issue and implement option (2). Yet the CMakeLists.txt below still results in @executable_path/libwupienginemac.dylib dependency.

Steps To Reproducecmake_minimum_required(VERSION 3.1)

project(xxx_test)

set(CMAKE_MACOSX_RPATH 1)
find_library(LIB_XXX lib_xxx
    PATHS "/path/to/lib_xxx/lib"
    )
if (NOT LIB_XXX)
    message(FATAL_ERROR ""LIB XXX not found")
 endif()

add_executable(xxx_test xxx_test.cpp)
target_link_libraries(xxx_test
    ${LIB_XXX}
)
# Try running the executable at once
add_custom_target(wibut_test_run ALL
    COMMAND xxx_test
    DEPENDS xxx_test
    )
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0039316)
Clinton Stimpson (developer)
2015-08-22 17:06

To clarify. CMAKE_MACOSX_RPATH affects creation of a library so that its "id" is prefixed with @rpath. CMAKE_MACOSX_RPATH has not effect on consumers of this library.

In your case, you are consuming a library outside the build tree, and wish to use @rpath to reference that library. As a consumer of that library, CMAKE_MACOSX_RPATH has no effect.

CMake does not add dependencies using @rpath, @executable_path or anything else. The linker is doing that. The linker takes the "id" of the library and uses that string when adding the dependency. You can use "otool -D" to print out the "id" of libwupienginemac.dylib, and you will see that it contains @executable_path. To use @rpath, you must edit that library, either by recompiling or by using install_name_tool to modify it.

If you need further help, you may use the mailing list.
(0040122)
Robert Maynard (manager)
2016-01-04 11:52

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-08-22 10:49 ovz New Issue
2015-08-22 17:06 Clinton Stimpson Note Added: 0039316
2015-08-24 09:23 Brad King Status new => resolved
2015-08-24 09:23 Brad King Resolution open => no change required
2016-01-04 11:52 Robert Maynard Note Added: 0040122
2016-01-04 11:52 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team