cmake and RPATH
Brad King
brad.king at kitware.com
Wed Mar 1 20:55:58 CET 2006
Alexander Neundorf wrote:
>>>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.
>
> Is there a way to avoid this relinking ?
Option #3 avoids relinking. The relinking rule is simple: if the rpath
used for the binary in the build tree is different from that of the
binary in the install tree then relinking is required.
>>>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.
>
> Do I have to set INSTALL_RPATH explicitely ?
Yes. It is a target property that is initalized when the target is
created from the variable CMAKE_INSTALL_RPATH, which is by default
empty. If all kdelibs libraries go in the same place in the install
tree you could just set CMAKE_INSTALL_RPATH to this location at the top
of the tree and it would work.
All the BUILD_WITH_INSTALL_RPATH option does is to link the binaries in
the build tree using the rpath that is desired for binaries in the
install tree. This way relinking is not needed before installing. One
still must set the desired INSTALL_RPATH if it is not empty.
>>>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.
>
> But it would avoid relinking, it would work without having the libs installed,
> and it would work with the libs installed and the builddir removed.
It would also favor the builddir version of libraries even when running
the installed executables. If the builddir version has been updated
things would break. Leaving the builddir in the installed binary rpath
is not an option.
> Does CMAKE_SKIP_RPATH override all other RPATH related options ?
Yes.
-Brad
More information about the Kde-buildsystem
mailing list