[CMake] CPack: Different installation prefixes per CPACK_GENERATOR
Rainer Poisel
rainer.poisel at gmail.com
Fri Jun 19 15:13:23 EDT 2015
Dear list,
how can I specify different installation prefixes for the different
CPACK_GENERATORs?
For example:
* the DEB package should be installed to `/opt/project`
* the TGZ archive should consist only of the `project` directory
>From the documentation I understood that I would have to use the
CPACK_PROJECT_CONFIG_FILE variable. Using that, it should be possible
to achieve the desired goal. However, it did not work for me.
This is my CPack configuration:
8<============================
set(CPACK_GENERATOR "DEB;TGZ")
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/package.linux.txt)
8<============================
And this is my ${CMAKE_SOURCE_DIR}/cmake/package.linux.txt file:
8<============================
IF (CPACK_GENERATOR MATCHES "DEB")
set(CPACK_NATIVE_INSTALL_DIRECTORY "/opt")
set(CMAKE_INSTALL_PREFIX "/opt")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
set(CPACK_INSTALL_DIRECTORY "/opt")
ELSEIF(CPACK_GENERATOR MATCHES "TGZ")
set(CPACK_NATIVE_INSTALL_DIRECTORY "")
set(CMAKE_INSTALL_PREFIX "")
set(CPACK_PACKAGING_INSTALL_PREFIX "")
set(CPACK_INSTALL_DIRECTORY "")
ENDIF()
8<============================
I ensured that all files get parsed using MESSAGE() directives, but
the prefix of my packages is always /usr/local.
Thanks for giving me a few hints,
Rainer
More information about the CMake
mailing list