about rpath "automagic" (CMAKE_INSTALL_RPATH)

René J.V. Bertin rjvbertin at gmail.com
Sat Jan 23 09:25:07 UTC 2016


Hello,

I've been building KF5 projects on OS X and Linux, using /opt/local as the install prefix, but with Qt5 tucked away partly into /opt/local/libexec/qt5 in order to allow it to co-exist with Qt4 in the same prefix.
The build system I use will typically turn on explicit rpaths if such a build option exists, but that isn't even always necessary on OS X as shared libraries (can) contain their own absolute install path. (In that case it's the link editor that adds the info to the product's rpath.)
IOW, it will add -DCMAKE_INSTALL_RPATH=/opt/local/lib to  the CMake arguments by default.

Not so on Linux, I just realised. For example, when I build QtCurve in "Qt only" mode, it will not contain a runtime search path for the Qt libraries, and will thus find the system libraries (or not). When I build with KF5 support enabled though, the correct Qt libraries are found all of a sudden. In both cases the actual link command uses the full path to the correct Qt libraries, so it's not the build system that finds the wrong library versions.

There is no explicit CMAKE_INSTALL_RPATH reconfiguration in QtCurve's CMake files, so whatever happens is handled automatically, somewhere. That somewhere must be in a KF5 cmake file and not one from Qt itself. KDECMakeSettings.cmake seems the most likely candidate, and I'd like to ask some questions about that file (hoping this is the right place):

1) I see it does `set(CMAKE_INSTALL_RPATH "${_abs_LIB_INSTALL_DIR}")` . Shouldn't that be `set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH;${_abs_LIB_INSTALL_DIR}"), IOW, shouldn't the additional path be appended (or prepended...) to the existing RPATH?!

2) I did find that I have to set `-DCMAKE_INSTALL_RPATH="/opt/local/lib/x86_64-linux-gnu\;/opt/local/lib"` on Linux, presumably because Kubuntu's multi-arch configuration is detected. Why does the build system not pick that fact up, while it clearly does pick up the non-standard Qt library locations? Maybe it considers /opt/local/lib/x86_64-linux-gnu a system location because cmake itself is installed under /opt/local ?

3) If KDECMakeSettings.cmake alters CMAKE_INSTALL_RPATH, is that supposed to be visible in CMakeCache.txt ? That cache file only shows the setting I passed on the commandline. If that means KDECMakeSettings.cmake doesn't do its job in my set-up, then the mystery stands how KF5 builds manage to add /opt/local/libexec/qt5/lib to the rpath ...

Thanks,
René


More information about the Kde-frameworks-devel mailing list