View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014198CMakeCPackpublic2013-06-04 10:062016-06-10 14:31
ReporterMark Stijnman 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake 2.8.10.1 
Target VersionFixed in Version 
Summary0014198: CPack doesn't make variables passed by -D available in CPackConfig.cmake
DescriptionWhen running CPack from the command line, the -D option allows you to pass variables to CPack. However, you can't use the values of these variables in the CPackConfig.cpack, which isn't what I expected. The documentation isn't clear on this either, although in http://www.cmake.org/Wiki/CMake:CPackConfiguration, [^] it says "Some variables may be set/overriden on the command line when invoking CPack", from which I suppose I could have deduced that the assignments from -D are only performed *after* CPack loads CPackConfig.cpack.

A workaround is readily available: the values from -D *are* available in the project-specific config file.

I think this should either be clearly described in the documentation of CPack, or solved. An easy solution could be to load the command line variables both *before* loading the CPackConfig.cmake file, and again *after* loading it. This way, the variables will be available in the CPackConfig.cmake, if the developer needs them there, while still ensuring that they overwrite whatever is in the CPackConfig.cmake.

I think the same thing could be done with the overrides from -C, -P and -R command line switches as well, which as far as I can tell also only get loaded *after* CPackConfig.cmake has already been included. Which means you can't do things like "set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION})" in your CPackConfig.cmake file and expect it to pick up the new CPACK_PACKAGE_NAME from the -P command line parameter.
Steps To Reproduce--- CPackConfig.cmake: ---

set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_NAME "test")
set(CPACK_PACKAGE_DESCRIPTION "A test package")
set(CPACK_PACKAGE_VERSION "0.1")
set(CPACK_INSTALL_COMMANDS "")
set(CPACK_PROJECT_CONFIG_FILE "CPackProjectConfig.cmake")

set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} ${CPACK_VERSION_TAG}")
message("Package file name in CPackConfig.cmake: ${CPACK_PACKAGE_FILE_NAME}")

--- CPackConfig.cmake end ---

--- CPackProjectConfig.cmake: ---

set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} ${CPACK_VERSION_TAG}")
message("Package file name in CPackProjectConfig.cmake: ${CPACK_PACKAGE_FILE_NAME}")

--- CPackProjectConfig.cmake end ---

Run:
cpack -D CPACK_VERSION_TAG="Beta" --config CPackConfig.cmake

Output:
Package file name in CPackConfig.cmake: test 0.1
Package file name in CPackProjectConfig.cmake: test 0.1 Beta
...

Expected output:
Package file name in CPackConfig.cmake: test 0.1 Beta
Package file name in CPackProjectConfig.cmake: test 0.1 Beta
...
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0042296)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-06-04 10:06 Mark Stijnman New Issue
2016-06-10 14:29 Kitware Robot Note Added: 0042296
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team