[CMake] install directory structure with <proj>-targets.cmake and <proj>-config.cmake

Zaak Beekman zbeekman at gmail.com
Wed May 7 11:57:34 EDT 2014


Looking at page 80 in 'Mastering CMake' fifth edition, is says that the
<proj>-targets.cmake "file contains code such as
`get_filename_component (_self "${CMAKE_CURRENT_LIST_FILE}" PATH)`
`get_filename_component (PREFIX "${_self}/../.." ABOSULTE)`"

I'm on Mac OS X using CMake 2.8.12 and was emulating a Linux style install
directory structure, meaning that I was putting libraries in
${CMAKE_INSTALL_PREFIX}/lib... header like files in
${CMAKE_INSTALL_PREFIX}/include and the <proj>-config.cmake and
<proj>-targets.cmake are getting installed to
${CMAKE_INSTALL_PREFIX}/share/<proj>

It seems, however, that the paths to targets in <proj>-targets.cmake are
always specified as
${CMAKE_CURRENT_LISTFILE}/<path-passed-as-DESTINATION-argument-to-install>.
This is of course a problem for me since, the paths to targets in the
installed <proj>-targets.cmake file are now wrong, they are not given the
correct location relative to that file.

Am I wrong in my assumption that the <proj>-targets.cmake file will know
where it is being installed and where all the project's targets are
installed and be able to compute relative or full paths to them? (It seems
as though it is doing this incorrectly at the moment)

Do I need to use a different directory structure for the install so that
the <proj>-targets.cmake and <proj>-config.cmake are installed in
${CMAKE_INSTALL_PREFIX}/<package-name> and the targets are installed in
appropriate subdirectories of that, like bin, lib, include, etc?

For reasons I don't understand, I could successfully import this project
when installed to the ${CMAKE_INSTALL_PREFIX} location and when installed
using `make DESTDIR=alternate/dir install` EXCEPT when using
CMAKE_MACOSX_RPATH=1 in the original project, the link step of the
importing project fails to pass -Wl,-rpath,path/to/installed/dylib

TIA,

Izaak Beekman
===================================
(301)244-9367
Princeton University Doctoral Candidate
Mechanical and Aerospace Engineering
ibeekman at princeton.edu

UMD-CP Visiting Graduate Student
Aerospace Engineering
ibeekman at umiacs.umd.edu
ibeekman at umd.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140507/a3286c3f/attachment-0001.html>


More information about the CMake mailing list