I'm having an issue with the RPATH not showing up for one of my shared libraries on OSX. Basically, I end up with a "bare" rpath to one of my shared libraries (i.e., no path prefix) when I check my binary using otool - L
Specifically, I have a project with a structure that looks like this project/module_A project/module_B I'm trying to build "Module B", which depends on a shared library I build in "Module A". (I also use several other shared libraries, but all of them are in system paths, i.e., /usr/local and /usr/lib.). What ends up happening is that all of the rpaths are set *except* for my shared library from Module A (for both the build and install versions of the binary). After carefully reading the CMake primer on RPath handling here: http://www.cmake.org/Wiki/CMake_RPATH_handling I tried the suggestion under "Always full rpath", i.e., my CMakeLists.txt file has the following: # use, i.e. don't skip the full RPATH for the build tree SET(CMAKE_SKIP_BUILD_RPATH FALSE) # when building, don't use the install RPATH already # (but later on when installing) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # the RPATH to be used when installing, but only if it's not a system directory LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) IF("${isSystemDir}" STREQUAL "-1") SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") ENDIF("${isSystemDir}" STREQUAL "-1") However, this still doesn't appear to be setting the RPATH variable for my dynamic library. I likewise checked that CMAKE_INSTALL_RPATH is set correctly (i.e., the library from Module A sits in that directory). However, nothing I do seems to prefix an RPATH directory to my shared library for Module A. One other thing - I've also tried building this code on Linux (Ubuntu-12.10), and I've noticed that the same configuration correctly sets the RPATH for Module A - so this seems to be specific to OSX. What am I missing here? Going through the list archives, I've seen this problem pop up a few times with respect to OSX, but I haven't really seen anything that specifically solves this issue. Specifically, this message from a few weeks ago seems to be running into the exact same issue, but I don't see any replies: http://www.cmake.org/pipermail/cmake/2013-January/053335.html The only other thread I've seen on this recently is here: http://www.cmake.org/pipermail/cmake/2011-April/043888.html The solution here was pretty much to either use install_name_tool manually (which does work, but it requires one to do it each time you build) or to use BundleUtilities. However, I noticed that CMake runs install_name_tool on its own for a library which is built with Module B (i.e., I have libModuleB_core.dylib which is built and linked into the moduleB binary); i.e., this shows up in cmake_install.cmake. So shouldn't there be some way to get CMake to appropriately run install_name_tool for me for Module A as well? Or at the very least, is there a reason no RPATH is being appended to Module A? Thanks. -Steve --- Steve Skutnik, Ph.D. http://neutroneconomy.blogspot.com
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake