[CMake] new RPATH support questions

William A. Hoffman billlist at nycap.rr.com
Mon Mar 6 14:57:03 EST 2006


At 02:16 PM 3/6/2006, Alexander Neundorf wrote:
>Hi,  
>  
>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 ?  
>  

There is no default install RPATH, so the default is empty.

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

Yes, and CMake is currently flaged as a dangerous tool by several OS's because it
installs programs with RPATH pointing back to the build tree.  This is a security
hole.   You should never install software that has an RPATH pointing back to
the build tree.  So, it is a bug fix, cmake should never have done this.  

> 
>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 is in both of them, and should be set for both.

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

This sounds good.

>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) 
> 
   
I don't understand why you have 2 and 3, would not 1 handle all cases?

>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. 
I suppose there are two types of people that will be building KDE, developers,
and users.   Users will build it once and install it.  For this group, an install
path compiled in should do the trick.   For developers, they would most likely not
install, and want RPATH as it has been, and the relink would not happen because they
would not install, but they want it to run out of the build tree.   Since the developers
are developers, they should have to turn on some option that says use RPATH, and
the docs would warn about the extra link at install time.

-Bill


-Bill



More information about the CMake mailing list