[CMake] Using CMAKE_INSTALL_PREFIX in custom install command fails with CPack

Martin Craig martin.craig at eng.ox.ac.uk
Thu Feb 9 06:08:28 EST 2017


Hi, got this problem which I've boiled down to a simple test case. My source dir contains just one file (realfile) and the installation should install this in bin and make a symlink from linkfile to it. This is the CMakeLists.txt file:

    cmake_minimum_required(VERSION 2.8.0)

    INSTALL(FILES realfile DESTINATION bin)
    INSTALL(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink realfile ${CMAKE_INSTALL_PREFIX}/bin/linkfile)")

    include(CPack)

This works fine with make install provided I can write to ${CMAKE_INSTALL_PREFIX}, however with make package, CMAKE_INSTALL_PREFIX is not apparently set to the temporary install location that CPack is using, and so it fails.

Any idea how I can work around this, or a better way of doing this task? I need it for creating symlinks, and also another install command which generates an index file in the install directory.

Thanks for any help,
Martin.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170209/6b88647e/attachment.html>


More information about the CMake mailing list