[CMake] new RPATH support questions

Brad King brad.king at kitware.com
Mon Mar 6 14:59:19 EST 2006


Alexander Neundorf wrote:
> I just updated from current cvs.  
>   
> CMakeLists.txt:  
>   
> add_library(foo SHARED foo.c)  
>   
> add_executable(footest main.c)  
>   
> target_link_libraries(footest foor)  
>   
> install_targets(/bin footest)  
> install_targets(/lib foo)  
>   
> This has the effect, that footest is initially linked with rpath to the  
> library in the build dir, and when installed it is linked again but  
> without RPATH. I thought it should be relinked to the install RPATH ?  

This is because no install rpath has been set and the default is empty. 
  The INSTALL_RPATH target property is used to set the install tree 
rpath.  See the documentation of SET_TARGET_PROPERTIES.

> Besides that, AFAIK previous cmake version didn't relink during  
> installation. Are you sure it is a good idea to change the default  
> behaviour ?  

The old behavior left the build tree rpath in the installed binary which 
is bad and was a common complaint.  The relink is actually preserving 
old behavior of allowing one to run the binary from the build tree.

> Does RPATH actually only exist for executables or also for shared 
> libraries ? Does it have to be set for both or is it enough if it is set 
> for the executables ? 

It may be set for both shared libraries and executables but only 
executables (and perhaps loadable modules) really need it.

> For KDE I plan the following: 
>  
> 1) CMAKE_SKIP_RPATH and create wrapper shell scripts which set 
> LD_LIBRARY_PATH 

This should be left as a user option because it overrides all other 
rpath settings and will leave out rpaths no matter what.

> 2) COMPILE_WITH_INSTALL_RPATH and INSTALL_RPATH= 
> ${CMAKE_INSTALL_PREFIX}/lib 
> (for building releases) 
>  
> 3) COMPILE_WITH_INSTALL_RPATH and INSTALL_RPATH= ${LIBRARY_OUTPUT_PATH;
> ${CMAKE_INSTALL_PREFIX}/lib 
> (for developers, so that it runs also from the builddir) 
>  
> Do you think this is sensible ? 
>  
> I think relinking is not a good option for KDE, since this will take 
> really a lot of time. 

This is a topic for the KDE list since it is a decision for that project 
and not CMake.

-Brad


More information about the CMake mailing list