[cmake-developers] [Review request] Topic install_CMAKE_INSTALL_RELATIVE

Daniele E. Domenichelli ddomenichelli at drdanz.it
Mon Dec 22 11:51:21 EST 2014


Hello all,

Please review the topic install_CMAKE_INSTALL_RELATIVE.

install: Add CMAKE_INSTALL_RELATIVE variable
http://www.cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=3b57fa0

This patch adds a a variable CMAKE_INSTALL_RELATIVE to install files in
CMAKE_INSTALL_PREFIX using relative path, even if an absolute path was
passed to the install() command.
This might be useful in some cases to create binary packages.
For example, CPack will refuse to create a relocatable package if files
are installed using absolute paths, even if inside the prefix.

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.

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

(You can probably use DESTDIR, calculating the relative path between the
original prefix and the new prefix, but I believe that's not the best
way to do it)

Since the usage of absolute path instead of relative is in most of the
cases just a an unwanted effect, I believe that using this variable,
could simplify this kind of tasks.
What do you think?


Cheers,
 Daniele


More information about the cmake-developers mailing list