[CMake] CMAKE_INSTALL_RPATH_USE_LINK_PATH is broken?

clinton at elemtech.com clinton at elemtech.com
Wed Jan 13 22:52:44 EST 2016


On Jan 8, 2016 8:16 PM, Elizabeth Fischer <rpf2116 at columbia.edu> wrote:
>
> Hello,
>
> I'm using cmake 3.4.1.  I'm trying to compile libraries & executables with an RPATH.  To that end, I use the following settings:
>>
>>
>> SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
>> SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
>> SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
>
>
> I then link in a lot of libraries.  However, ONLY ONE of the libraries gets picked up to be used in the RPATH sent to the linker.  I can manually set CMAKE_INSTALL_RPATH (that works).  But CMAKE_INSTALL_RPATH_USE_LINK_PATH seems to be broken.
>
> Interestingly, the one library it's willing to auto-generate an RPATH for is the same library, whether it comes first or last in the link command line.  The link command generated by CMake is shown below; it's clear that many libraries are being linked in, but only one rpath is being generated.


Did you check that the libraries you are linking against have an install name starting with @rpath?

For example, 
otool -D /Users/rpfische/eb/software/netCDF/4.3.2-mpgompi-4.9.3/lib/libnetcdf.dylib

CMake will only consider adding an rpath for a library if the install name starts with @rpath.

Clint

>
> HELP!!!!?
> --- Elizabeth
>
>> [ 30%] Linking CXX executable test_array
>>
>> cd /Users/rpfische/git/spsparse/build/test && /Users/rpfische/macports/mpgompi-4.9.3/bin/cmake -E cmake_link_script CMakeFiles/test_array.dir/link.txt --verbose=1
>>
>> /Users/rpfische/macports/mpgompi-4.9.3/bin/g++   -g -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/test_array.dir/test_array.cpp.o  -o test_array  /Users/rpfische/eb/software/gtest/1.7.0-GCC-4.9.3/lib/libgtest.a /Users/rpfische/eb/software/gtest/1.7.0-GCC-4.9.3/lib/libgtest_main.a /Users/rpfische/eb/software/netCDF/4.3.2-mpgompi-4.9.3/lib/libnetcdf.dylib /Users/rpfische/eb/software/netCDF-C++4/ecdf914-mpgompi-4.9.3/lib/libnetcdf-cxx4.dylib /Users/rpfische/eb/software/ibmisc/devel/lib/libibmisc.dylib ../slib/libspsparse.dylib /Users/rpfische/eb/software/netCDF/4.3.2-mpgompi-4.9.3/lib/libnetcdf.dylib /Users/rpfische/eb/software/netCDF-C++4/ecdf914-mpgompi-4.9.3/lib/libnetcdf-cxx4.dylib /Users/rpfische/eb/software/ibmisc/devel/lib/libibmisc.dylib -Wl,-rpath,/Users/rpfische/eb/software/ibmisc/devel/lib 


More information about the CMake mailing list