[CMake] CMake shared libraries, install, and rpath

Alexander Neundorf a.neundorf-work at gmx.net
Wed Mar 18 19:13:59 EDT 2009


On Wednesday 18 March 2009, Bartlett, Roscoe A wrote:
> Hello,
>
> How can we get CMake to deal with installed shared libraries and set the
> rpath correctly in a portable way?  The issue is that we have is that we
> need to enable client applications to link to installed Trilinos shared
> libraries and provide for them, in an automatic way, the right link line so
> that they can build and run the executable without having to set
> LD_LIBRARY_PATH manually.  

Yes, cmake can do that for you.
Please have a look at set_target_properties(), there are several RPATH-related 
properties.
The simplest thing to do should be just to set
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
This should cause cmake to reuse the RPATH it used for the buildtree (there it 
uses the full RPATH which includes all linked libraries) also for the install 
tree, except the directories which point into the buildtree.
If you need to add further directories to the installed RPATH, you can set the 
INSTALL_RPATH property (or the CMAKE_INSTALL_RPATH variable) to these 
additional directories.

> Also, these clients will be using dumb makefiles
> and we provide to them an "export makefile" fragment that they just include
> and it defines all of the needed compile and link flags and libraries.

Are you sure you want to do this ?
This will probably cause problems. 
Are there real problems with also shipping them a suitable cmake version ?

Alex


More information about the CMake mailing list