[cmake-developers] [PATCH] CPack: change cpack_set_if_not_set into a function
Роман Донченко
dpb at corrigendum.ru
Tue Mar 3 13:33:55 EST 2015
Since it's currently a macro, then due to macro processing rules, special
characters inside the value are interpreted by the parser, which can
result in syntax errors or a mismatch between the given default and the
value the variable is actually set to.
Remove existing local workarounds for this issue, which are no longer
required.
---
Modules/CPack.cmake | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index 532596d..4b10723 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -298,12 +298,12 @@ endif()
# Include CPackComponent macros if it has not already been included before.
include(CPackComponent)
-# Macro for setting values if a user did not overwrite them
-macro(cpack_set_if_not_set name value)
+# Function for setting values if a user did not overwrite them
+function(cpack_set_if_not_set name value)
if(NOT DEFINED "${name}")
- set(${name} "${value}")
+ set(${name} "${value}" PARENT_SCOPE)
endif()
-endmacro()
+endfunction()
# cpack_encode_variables - Macro to encode variables for the configuration file
# find any variable that starts with CPACK and create a variable
@@ -534,9 +534,7 @@ endif()
cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
if(CPACK_NSIS_DISPLAY_NAME_SET)
- string(REPLACE "\\" "\\\\"
- _NSIS_DISPLAY_NAME_TMP "${CPACK_NSIS_DISPLAY_NAME}")
- cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${_NSIS_DISPLAY_NAME_TMP}")
+ cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}")
else()
cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
endif()
@@ -604,7 +602,7 @@ cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
- "/CVS/;/\\\\\\\\.svn/;/\\\\\\\\.bzr/;/\\\\\\\\.hg/;/\\\\\\\\.git/;\\\\\\\\.swp$;\\\\\\\\.#;/#")
+ "/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
--
2.1.4
More information about the cmake-developers
mailing list