Re: [cmake-developers] [PATCH] CPack: don't mangle CMake-special characters when applying default settings

2015-09-09 Thread Domen Vrankar
2015-09-03 22:00 GMT+02:00 Роман Донченко :
> By using a function to do it instead of a macro. Deprecate the old macro,
> but keep it for backwards compatibility. Remove existing workarounds for this
> problem and add a test.

Applied with minor changes to next for testing:
http://www.cmake.org/gitweb?p=cmake.git;a=commit;h=2a7772f

Thanks,
Domen
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

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

[cmake-developers] [PATCH] CPack: don't mangle CMake-special characters when applying default settings

2015-09-03 Thread Роман Донченко
By using a function to do it instead of a macro. Deprecate the old macro,
but keep it for backwards compatibility. Remove existing workarounds for this
problem and add a test.
---
 Help/release/dev/CPack-updates.rst |  6 ++
 Modules/CPack.cmake| 92 ++
 Tests/RunCMake/CPackConfig/Default-check.cmake |  7 ++
 Tests/RunCMake/CPackConfig/Default.cmake   |  3 +
 Tests/RunCMake/CPackConfig/RunCMakeTest.cmake  |  1 +
 Tests/RunCMake/CPackConfig/check.cmake |  4 ++
 6 files changed, 70 insertions(+), 43 deletions(-)
 create mode 100644 Help/release/dev/CPack-updates.rst
 create mode 100644 Tests/RunCMake/CPackConfig/Default-check.cmake
 create mode 100644 Tests/RunCMake/CPackConfig/Default.cmake

diff --git a/Help/release/dev/CPack-updates.rst 
b/Help/release/dev/CPack-updates.rst
new file mode 100644
index 000..7ac1ed7
--- /dev/null
+++ b/Help/release/dev/CPack-updates.rst
@@ -0,0 +1,6 @@
+CPack-updates
+-
+
+* The :module:`CPack` module no longer mangles settings with CMake-special
+  characters when they're used as defaults for other settings. The macro
+  ``cpack_set_if_not_set``, which was responsible for this, is now deprecated.
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index e223286..9fe349c 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -299,10 +299,10 @@ endif()
 include(CPackComponent)
 
 # Macro for setting values if a user did not overwrite them
+# Mangles CMake-special characters. Only kept for backwards compatibility.
 macro(cpack_set_if_not_set name value)
-  if(NOT DEFINED "${name}")
-set(${name} "${value}")
-  endif()
+  message(DEPRECATION "cpack_set_if_not_set is obsolete; do not use.")
+  _cpack_set_default("${name}" "${value}")
 endmacro()
 
 # cpack_encode_variables - Macro to encode variables for the configuration file
@@ -321,27 +321,35 @@ macro(cpack_encode_variables)
   endforeach()
 endmacro()
 
+# Internal use functions
+
+function(_cpack_set_default name value)
+  if(NOT DEFINED "${name}")
+set("${name}" "${value}" PARENT_SCOPE)
+  endif()
+endfunction()
+
 # Set the package name
-cpack_set_if_not_set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
-cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
-cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
-cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
-cpack_set_if_not_set(CPACK_PACKAGE_VERSION
+_cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
+_cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
+_cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
+_cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
+_cpack_set_default(CPACK_PACKAGE_VERSION
   
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
-cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
-cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
+_cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
+_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
   "${CMAKE_PROJECT_NAME} built using CMake")
 
-cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE
+_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
   "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
-cpack_set_if_not_set(CPACK_RESOURCE_FILE_LICENSE
+_cpack_set_default(CPACK_RESOURCE_FILE_LICENSE
   "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
-cpack_set_if_not_set(CPACK_RESOURCE_FILE_README
+_cpack_set_default(CPACK_RESOURCE_FILE_README
   "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
-cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME
+_cpack_set_default(CPACK_RESOURCE_FILE_WELCOME
   "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
 
-cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
+_cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
 
 if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
   set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
@@ -359,7 +367,7 @@ if(__cpack_system_name MATCHES "Windows")
 set(__cpack_system_name win32)
   endif()
 endif()
-cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}")
+_cpack_set_default(CPACK_SYSTEM_NAME "${__cpack_system_name}")
 
 # Root dir: default value should be the string literal "$PROGRAMFILES"
 # for backwards compatibility. Projects may set this value to anything.
@@ -369,17 +377,17 @@ if("x${__cpack_system_name}" STREQUAL "xwin64")
 else()
   set(__cpack_root_default "$PROGRAMFILES")
 endif()
-cpack_set_if_not_set(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
+_cpack_set_default(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
 
 # -..--.
-cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
+_cpack_set_default(CPACK_PACKAGE_FILE_NAME
   "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
-cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
+_cpack_set_default(CPACK_PACKAGE_INSTALL_DIRECTORY
   "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
-cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY