0

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.

katang
  • 2,474
  • 5
  • 24
  • 48

1 Answers1

3

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

set(CPACK_PACKAGING_INSTALL_PREFIX "$ENV{HOME}/${CPACK_PACKAGE_NAME}")
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • 1
    I'm pretty sure this does not work. The environment variable is evaluated at the time of configuring the project. If the home directory is different when you install the package, the data is installed to the wrong location. This would even occur when changing the user on the same machine. – fabian Oct 20 '20 at 19:07
  • In CMake installation prefix is set when the project is configured. If the project is configured by one user and is installed by **another** user, then the question - "install the project into the user's home directory" - has no sense, as it doesn't specify the user which home directory is intended to be used as the installation one. – Tsyvarev Oct 20 '20 at 19:26