[CMake] new RPATH support questions

Brad King brad.king at kitware.com
Tue Mar 7 09:05:23 EST 2006


Alexander Neundorf wrote:
> Ok, I tested now the following: 
>  
> set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 
> set(CMAKE_SKIP_BUILD_RPATH TRUE) 
>  
> set(CMAKE_INSTALL_RPATH ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/  
>                         ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}) 
>  
> Which gives
> 
> CMAKE_INSTALL_RPATH=/home/alex/src/kde4-svn/kdelibs-build/lib/.:/opt/kde4/lib
> 
> as expected.  
> When linking, this is then used for RPATH. 
> This should have the effect that it can be installed without relinking 
> and that it has RPATH both to the build dir and to the install dir set. 
>  
> Before these changes, there was also the directory to the Qt libs 
> (/usr/lib/qt4/lib) used for the RPATH. This is gone now, I didn't expect 
> this. I expected that only the paths to the libraries compiled within 
> this project would be removed by setting CMAKE_SKIP_BUILD_RPATH to true. 
>  
> Is this a bug or a feature ? If it's a feature, why has it been 
> implemented this way ? 

The default policy is really simple:

1.) Binaries in the build tree should be able to run without 
LD_LIBRARY_PATH so the rpath is configured to be the same as the link 
library search path (-L options).

2.) Binaries in the install tree should have whatever rpath is specified 
by the developer (via INSTALL_RPATH) without any magic, and by default 
no rpath at all.  CMake cannot know the final organization for outside 
libraries intended by the developer so no guesses are made.  For 
example, what if a Qt build tree was used to provide Qt to your 
project's build tree but they would both be installed and distributed 
together?

-Brad


More information about the CMake mailing list