[cmake-developers] [Review request] Topic install_CMAKE_INSTALL_RELATIVE

Domen Vrankar domen.vrankar at gmail.com
Mon Dec 22 15:28:02 EST 2014


> In my experience, I found that many projects install files using
> absolute paths, even when they should be installed using a path relative
> to the CMAKE_INSTALL_PREFIX. This makes it impossible to package them
> using CPack without large modification of the cmake code.

Maybe others will disagree but to be quite honest I myself don't think
that CMAKE_INSTALL_RELATIVE variable would be the right solution... I
myself prefer to write install commands with relative paths and I
guess that something like that should be fixed in CMakeLists.txt and
contributed to projects that use absolute paths and not add a new
variable for doing this... (maybe someone decided to leave some paths
absolute for a reason e.g. symlinks or system/program requirements for
certain files).

> Moreover it makes it hard to install only one component in a different
> prefix, for example using:
>
>   cmake -DCMAKE_PREFIX_PATH=/new/prefix -DCOMPONENT=foo \
>     -P cmake_install.cmake

This is again something that can be solved by using for e.g.
GNUInstallDirs.cmake module and adding the paths set in this module to
paths provided to install commands.

As for CPack and different locations... I don't know about other
packagers but for RPM packages I wrote a patch a few weeks ago that
uses GNUInstallDirs.cmake and provides option to have more than one
relocation path per RPM package. The reason that I haven't contributed
it yet is that I still have to write tests for the code (I'll do this
in the following days) before submitting the patch for review.

Preview patch is attached.

Regards,
Domen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-multiple-path-relocation-prefixes.patch
Type: text/x-diff
Size: 7455 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20141222/532069ab/attachment.patch>


More information about the cmake-developers mailing list