I've run into some trouble with how CMake 2.4.2 (and perhaps later) handles the string "$ORIGIN" when it appears as part of an RPATH. I've gotten around the trouble (see below), but would appreciate any pointers on the correct way to use "$ORIGIN".
Regards, Iker Briefly, the problem seems to be that CMake inconsistently carries out the expansion of the "$ORIGIN" string. If one extends the install rpath like so: SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN/../xxx") the rpath for an installed executable or shared library ends up like this (using readelf -d): 0x0000000f (RPATH) Library rpath: [/home/iker/tmp/rpath_test/xxx] 0x0000001d (RUNPATH) Library runpath: [/home/iker/tmp/rpath_test/xxx] where "/home/iker/tmp/rpath_test" is the path to my build tree. The "$ORIGIN" token disappears. If the above test is changed so that the ".." is removed: SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN/xxx") the rpath handling differs. The rpath for an installed executable now looks like this: 0x0000000f (RPATH) Library rpath: [/home/iker/tmp/rpath_test/:RIGIN/xxx] 0x0000001d (RUNPATH) Library runpath: [/home/iker/tmp/rpath_test/:RIGIN/xxx] Note that "$ORIGIN" has been truncated to "RIGIN". The rpath for an installed shared library seems to do the right thing: 0x0000000f (RPATH) Library rpath: [/home/iker/tmp/rpath_test/:$ORIGIN/xxx] 0x0000001d (RUNPATH) Library runpath: [/home/iker/tmp/rpath_test/:$ORIGIN/xxx] To get around the two problems above I tried setting the linker flag variables directly: SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN/../xxx/'" ) SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN/../xxx'" ) For installed shared libraries we get the right behavior: 0x0000000f (RPATH) Library rpath: [$ORIGIN/../xxx] 0x0000001d (RUNPATH) Library runpath: [$ORIGIN/../xxx] But not for installed executables: 0x0000000f (RPATH) Library rpath: [RIGIN/../xxx/] 0x0000001d (RUNPATH) Library runpath: [RIGIN/../xxx/] To fix the problem with executables I tried adding an extra "$" character like this: SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,'$$ORIGIN/../xxx/'" ) And, on my system (Gentoo 1.2, Intel x86), this solves the problem for exes: 0x0000000f (RPATH) Library rpath: [$ORIGIN/../xxx/] 0x0000001d (RUNPATH) Library runpath: [$ORIGIN/../xxx/] Unfortunately, on CentOS 4.6 systems using the same CMake release (2.4.2) the behavior with respect to shared libs and exes is the opposite of what it is on my system. That is, the shared library flags require the special "$$ORIGIN" string and exes work fine with "$ORIGIN". To get the right behavior and ensure that my CMake files work across all of our machines I resorted to using both forms: $ORIGIN/../xxx/:$$ORIGIN/../ which clutters the resulting rpaths but gets the job done. -- Iker Arizmendi AT&T Labs - Research Speech and Image Processing Lab e: [EMAIL PROTECTED] w: http://research.att.com p: 973-360-8516 _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake