[CMake] RPATH questions

Brad King brad.king at kitware.com
Mon Jul 24 11:14:16 EDT 2006


Alan W. Irwin wrote:
> I build modules with cmake which depend on external libraries which may be
> installed in non-standard locations.  The modules also depend on cmake
> targets.  These modules are checked at build time with a small application
> that dynamically loads them. These modules are also installed (possibly
> using a non-standard install prefix). Thus, the build-tree version and
> installed version of the modules need different rpaths.  For the build-tree
> version I want to set an RPATH to access the directories of external
> libraries and the build-tree targets. For the installed version I want to
> set an RPATH to access the directories of the external libraries and the
> install-tree targets.
> 
> If I simply specify the cmake targets and the fullpathname of the external
> libraries which the module depends on using TARGET_LINK_LIBRARIES will
> CMake
> automatically do what I want with RPATH?  Or do I have to use some
> combinations of the RPATH-related properties specified in the man page for
> SET_TARGET_PROPERTIES.  Or some combination of the two approaches?

If you don't set BUILD_WITH_INSTALL_RPATH or SKIP_BUILD_RPATH properties
then the modules built into the build tree will have the proper rpath to
load from there.  Then just set the INSTALL_RPATH property to the
desired rpath for the installed version.  When you run "make install" a
separate copy will be linked and installed with the modified rpath.

Summary:  Just set INSTALL_RPATH on the module target to be the rpath
needed in the install tree.  Then things will just work.

-Brad


More information about the CMake mailing list