[CMake] rpath trouble on macosx: cmake 2.8.9 ignores INSTALL_NAME_DIR and INSTALL_RPATH?
Dan Kegel
dank at kegel.com
Tue Sep 10 12:43:59 EDT 2013
Howdy!
I'm using 2.8.9 installed on MacOSX using macports, and am trying to get
a minimal example of rpath working.
Doing it without cmake works fine; see
http://kegel.com/macosx/rpath/demo.txt
which just does
gcc -shared foo.c -install_name @rpath/foo.so -o foo.so
gcc -Wl,-rpath $OTHERDIR x.c foo.so
and works fine.
But doing it with cmake eludes me. Here's what I'm trying:
http://kegel.com/macosx/rpath/demo2.txt
http://kegel.com/macosx/rpath/CMakeLists.txt
That CMakeLists.txt is just
cmake_minimum_required(VERSION 2.8)
set(MYLIBDIR "${CMAKE_SOURCE_DIR}/otherdir")
add_library(foo SHARED foo.c)
set_target_properties(foo PROPERTIES INSTALL_NAME_DIR "@rpath")
add_executable(x x.c)
set_target_properties(
x
PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH ${MYLIBDIR}
)
target_link_libraries(x foo)
When I run demo2.txt, it does
/usr/bin/gcc -dynamiclib -Wl,-headerpad_max_install_names -o
libfoo.dylib -install_name /Users/dank/rpath/btmp/libfoo.dylib
CMakeFiles/foo.dir/foo.c.o
/usr/bin/gcc -o CMakeFiles/x.dir/x.c.o -c /Users/dank/rpath/x.c
/usr/bin/gcc -Wl,-search_paths_first
-Wl,-headerpad_max_install_names CMakeFiles/x.dir/x.c.o -o x
libfoo.dylib
and it appears to have totally ignored INSTALL_RPATH,
so naturally running x fails with
dyld: Library not loaded: /Users/dank/rpath/btmp/libfoo.dylib
Can I buy a clue, please?
More information about the CMake
mailing list