Search code examples
cmakecpack

How to install binaries to user's home directory by CPack?


I am trying to change package install prefix, with the goal to enable users of my application to install my app into their own directory. I attempted

set(CPACK_PACKAGING_INSTALL_PREFIX "~/${CPACK_PACKAGE_NAME}")

which results in error message

file called with relative DESTINATION.

at the same time,

set(CPACK_PACKAGING_INSTALL_PREFIX "./${CPACK_PACKAGE_NAME}")

works fine. Till now I guessed that "." is relative and "~" is absolute.

My real purpose to install a directory structure in the user's subdirectory, where samples, docs, logs can be located. I cannot figure out, how it should be carried out.


Solution

  • You may use environment variable HOME for refer to user's home directory:

    set(CPACK_PACKAGING_INSTALL_PREFIX "$ENV{HOME}/${CPACK_PACKAGE_NAME}")