[CMake] What is a good way to exclude default library locations from install-tree rpaths?
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Fri Jan 29 15:55:07 EST 2010
If target_link_libraries is given the full path to an external library, then
by default CMake uses rpath on Linux so that library is found at run time
for the build tree. For PLplot I have adjusted the RPATH options so that
the install-tree rpath is similarly well determined for all our external
However, there is one difference between the build-tree rpaths handled
automatically by CMake and our install-tree rpaths that I would like to
address. CMake is smart enough so that standard
locations (e.g., /usr/lib) which are automatically searched in any case by
the run-time loader are filtered out of the build-tree rpaths.
Currently, I don't have any functionality for removing standard locations
from the install-tree rpaths. Therefore, I am getting the following results
from the install:
-- Set runtime path of
"/home/software/plplot_svn/installcmake/lib/libplplotd.so .9.7.0" to
/home/software/plplot_svn/installcmake/lib gives run-time access to all
other PLplot libraries will install in that location, and
/home/software/qhull/install/lib is supposed to give run-time access to a
special version of qhull that I built. However, since /usr/lib is higher in
the colon-separated list it interferes with that so that the system version
of qhull in /usr/lib/ is being found instead of the special version.
Now, in general, our install rpaths are made up of a number of components
from various external libraries so which ones are installed in standard
locations and which ones are installed in special locations is not
predictable in advance. The above /usr/lib is coming from one of those
external libraries (libfreetype). If I swapped the order of libfreetype and
qhull, it would solve the problem for this particular test case, but not in
general where someone else might have a non-standard location for
libfreetype, but not for libqhull.
Obviously what is needed here is a convenient way to filter out standard
locations from the install-tree rpaths.
One possibility is I could always filter out /usr/lib from all such lists.
However, I am not sure that would work on all Unix platforms, and in any
case some platforms (including some Linux distros) have additional standard
locations that should be removed. Thus, I suspect CMake has a more
sophisticated platform-dependent method for filtering standard locations
from the build-tree rpath.
It would be nice if CMake made that filtering algorithm available for the
install-tree rpath, but if that is not easy to do with (say) an additional
target option could some CMake developer tell me where the build tree rpath
filtering rules are located in the CMake code so I could duplicate them for
our install-tree rpaths?
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
More information about the CMake