about rpath "automagic" (CMAKE_INSTALL_RPATH)

Alex Merry alex.merry at kde.org
Sun Feb 7 11:50:45 UTC 2016

On 2016-01-27 14:59, René J. V.  Bertin wrote:
> 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}")` .
> ${_abs_LIB_INSTALL_DIR}"), IOW, shouldn't the additional path be 
> appended (or
> prepended...) to the existing RPATH?!

Quite possibly. I suspect the original author didn't account for the 
possibility that someone might want to explicitly specify such a path on 
the command line.

> 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 ?

The mechanism by which packages are found is completely independent, and 
(more or less) involves CMake searching the filesystem recursively for 
*Config.cmake files, which then tell it where to find, say, Qt. Our 
RPATH handling logic isn't clever enough to account for found packages, 

It's possible that CMake could figure out the necessary RPATH settings 
itself. It's worth re-visiting this, I think.

> 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 ...

No. The fact that it is in the CMakeCache.txt at all is just an artifact 
of you passing it on the command line. The lookup sequence for variables 
is to check runtime-set variables, and only fall back to the cache if a 
variable hasn't been set at runtime.


More information about the Kde-buildsystem mailing list