The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14198 
====================================================================== 
Reported By:                Mark Stijnman
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14198
Category:                   CPack
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-06-04 10:06 EDT
Last Modified:              2013-06-04 10:06 EDT
====================================================================== 
Summary:                    CPack doesn't make variables passed by -D available
in CPackConfig.cmake
Description: 
When 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
...
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-06-04 10:06 Mark Stijnman  New Issue                                    
======================================================================

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to