[CMake] Problem: Cannot change name of installer package with CPack

Eric Noulard eric.noulard at gmail.com
Fri Jul 8 06:38:11 EDT 2011


2011/7/7 Stephen Torri <stephen.torri at gmail.com>:
> Problem: Cannot change name of installer package.
> Cmake version: 2.8.4

What is your platform/build tool?
Windows/ Visual Studio?
Linux / Makefiles?

Which CPack generator are you using?

>
> I am trying to change the value of CPACK_PACKAGE_NAME depending upon which
> build was performed. What I am seeing is that CPACK_PACKAGE_NAME is always
> set to the project name. The code I am using to try and change the name is
> below. How can I change the CPACK_PACKAGE_NAME value depending upon if I
> send Debug or Release as an option to cpack (e.g. cpack -C Debug)?
>
> IF(CMAKE_BUILD_TYPE MATCHES Release)
>   SET(CPACK_PACKAGE_NAME ${PROJECT_NAME} )
>   MESSAGE(STATUS "Project name: " ${CPACK_PACKAGE_NAME} )
> ELSEIF(CMAKE_BUILD_TYPE MATCHES Debug)
>   SET(CPACK_PACKAGE_NAME "${PROJECT_NAME}_debug")
>   MESSAGE(STATUS "Project name: " ${CPACK_PACKAGE_NAME} )
> ENDIF(CMAKE_BUILD_TYPE MATCHES Release)

Do you modify the CPACK_PACKAGE_NAME value
**before**

include(CPack)

?

It should work, unless you use a "multi-config" capable IDE like Visual Studio.

In this case and if you want to support more "dynamic" things you could use
a CPACK_PROJECT_CONFIG_FILE as described here:
http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#Overall_usage_.28common_to_all_generators.29

> send Debug or Release as an option to cpack (e.g. cpack -C Debug)?

I missed that in the first place.
You NEED to use CPACK_PROJECT_CONFIG_FILE if you want to change
some CPACK_xxx values  at CPack time.

The variable set in CMakeLists.txt are evaluated **at CMake time**
cpack won't always re-run CMake if launched with "cpack -C Debug".

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list