cmake and RPATH
Brad King
brad.king at kitware.com
Wed Mar 1 19:55:14 CET 2006
Alexander Neundorf wrote:
> Ok, how about these options for KDE:
>
> 1) Build without RPATH at all:
>
> set(CMAKE_SKIP_RPATH ON)
This is correct.
> 2) Build with RPATH to the builddir:
>
> # nothing required, no relinking will happen
This is the default, but relinking WILL happen on install to remove the
rpath or setup the rpath specified by the INSTALL_RPATH target property.
> 3) Build with RPATH only to the install dir:
>
> set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
>
> With this option executables will not run if the libs have not yet been
> installed.
This option will avoid the relinking for installation.
> 4) Build with RPATH to both install and build dir
>
> set_target_properties( kde-config PROPERTIES INSTALL_RPATH
> "${LIBRARY_OUTPUT_DIR};${LIBRARY_INSTALL_PATH}" )
>
> Is this possible ?
> If yes, will this have the effect that the linker will first look in the
> builddir and after that in the install dir ? If so, is this the desired
> order ?
This is not a good idea. First, the INSTALL_RPATH is not used in the
build tree unless option #3 above is set. Second, this will go back to
installing binaries that have an rpath pointing back at the build tree.
> For 1) and 3): The executables will not run without the libs already
> installed. For this case simple shell scripts could be created which set
> (DY)LD_LIBRARY_PATH accordingly, so that these executables can be run by
> running the small wrapper shell scripts.
>
> Do we need all these four options ? Or is our preferred option actually still
> missing ? Personally I'd like to have option 1) available.
If we go with this:
option(KDE4_BUILD_FOR_DEVELOPER "Enable running from build tree." OFF)
if(NOT KDE4_BUILD_FOR_DEVELOPER)
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
endif(NOT KDE4_BUILD_FOR_DEVELOPER)
then users who build and install KDE will not have to do anything
special and the installed binaries will have the proper install-tree
rpath. Developers who wish to have the option of running from the build
tree may enable this option at the expense of requiring the automatic
relinking before installation.
Option #1 is always available because CMake always creates
CMAKE_SKIP_RPATH as an advanced cache option. Developers may simply
enable that and then no rpath will be used no matter what the project does.
-Brad
More information about the Kde-buildsystem
mailing list