Alexander Neundorf wrote:
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.

Documentation for the RPATH properties is here:

http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:INSTALL_RPATH
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:INSTALL_RPATH_USE_LINK_PATH
http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:CMAKE_INSTALL_RPATH
http://www.cmake.org/cmake/help/cmake2.6docs.html#variable:CMAKE_INSTALL_RPATH_USE_LINK_PATH

These can help you set the RPATH that shared libraries and executables built
inside Trilinos use to locate each other.  If a third party executable links to
a Trilinos shared library then that executable needs to be built with its own
rpath flags to find the library at runtime.  However, if the Trilinos libraries
are spread in multiple locations and the outside executable needs only one of
them then it only needs its RPATH to find that one.  If that library depends on
more Trilinos libraries from other locations then it's RPATH will help it find
them even if the executable doesn't know where to look.

-Brad
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to