[CMake] Relink during install to get correct rpath in the binary?
Brad King
brad.king at kitware.com
Sun Nov 20 11:15:56 EST 2005
Lars Nordlund wrote:
> I was under the impression that CMake automatically did a relink
> against shared libraries during install? I can however not get that to
> happen. I made a shared library and a binary which links against it.
> The rpath is always pointing into my temporary tree of generated
> makefiles and build results. Is there a CMake variable controlling this
> behaviour?
CMake does not relink on installation. If any of the documentation gave
you that impression please let me know so it can be fixed.
The rpath feature of CMake is intended to help developers use projects
with shared libraries from the build tree without setting
LD_LIBRARY_PATH or their platform's equivalent. Many linux/unix people
consider rpaths evil for installed programs, and many linux
distributions ban them altogether. The idea is that installed shared
libraries should be in the system's shared library search path
(ld.so.conf or equivalent) so they can be shared among applications.
We recommend that when building an appliction for installation that the
CMake cache variable CMAKE_SKIP_RPATH:BOOL=ON be set to disable
inclusion of rpaths when linking. If you want an application to have
shared libraries in a non-system search path but still find them at
runtime you can do something like what is done in ParaView
(www.paraview.org).
ParaView has several executables which share a bunch of code that is
useful only to those executables. All the real executables and shared
libraries get installed in "lib/paraview-2.4/...". Small c-only
executables that link to nothing get installed in "bin/..." and just set
the environment properly and exec the real executables. See here for
the code:
http://www.paraview.org/cgi-bin/viewcvs.cgi/VTK/Utilities/kwsys/SharedForward.h.in?rev=HEAD&root=ParaView&view=auto
http://www.paraview.org/cgi-bin/viewcvs.cgi/Servers/Executables/pv-forward.c.in?rev=HEAD&root=ParaView&view=auto
This is similar to other applications that use a shell script for the
same purpose but it doesn't depend on a particular shell syntax and it
works on Windows too.
-Brad
More information about the CMake
mailing list