Automatically setting the RPATH - make use of $ORIGIN ?

Alexander Neundorf neundorf at kde.org
Sat Feb 23 10:51:25 UTC 2013


Hi,

in kdelibs4 and, when using FindKF5.cmake, we set the RPATH automatically by 
using the cmake target property INSTALL_RPATH_USE_LINK_PATH, and additionally 
we add ${LIB_INSTALL_DIR} if it is not a system library directory.

This means we set a bunch of absolute directories as RPATH.
RPATH supports $ORIGIN, which seems to refer to the location of the current 
ELF file.
Using $ORIGIN ELF files can be made, at least in this regard, relocatable.
When using INSTALL_RPATH_USE_LINK_PATH, cmake sets all paths to already 
installed libraries. It does not add the path to shared libraries from the 
current installation, that's why we add LIB_INSTALL_DIR.

So we could use $ORIGIN in shared libraries we install (so they find other 
shared libs in the same directory), $ORIGIN/../ in plugins and $ORIGIN/../lib/ 
in executables (not completely correct, but it should show the idea).

But now that we don't have kde4_add_executable(), kde4_add_library() and 
kde4_add_plugin() anymore, we cannot easily do this.

Should I try to get this into cmake, so it makes use of $ORIGIN when suitable 
?
Or should we leave it to the developers to set RPATH that way ?
Or do we want to keep those macros ?

Alex

(... I guess I know the answer. but won't that make us require new versions of 
cmake quite often ?)


More information about the Kde-buildsystem mailing list