From 4e9564a0f161cc6b5fb18eb8ee4d406285e6cab1 Mon Sep 17 00:00:00 2001
From: Andy Cedilnik <andy.cedilnik@kitware.com>
Date: Sun, 23 Apr 2006 19:45:43 -0400
Subject: [PATCH] ENH: Propagate system name and handle win32/win64 name

---
 Modules/CPack.cmake      | 16 +++++++++++++---
 Modules/NSIS.template.in |  2 ++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index 0f84c8c70a..25785a0663 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -52,9 +52,19 @@ IF(CPACK_NSIS_MODIFY_PATH)
   SET(CPACK_NSIS_MODIFY_PATH ON)
 ENDIF(CPACK_NSIS_MODIFY_PATH)
 
+SET(__cpack_system_name ${CMAKE_SYSTEM_NAME})
+IF(${__cpack_system_name} MATCHES Windows)
+  IF(CMAKE_CL_64)
+    SET(__cpack_system_name win64)
+  ELSE(CMAKE_CL_64)
+    SET(__cpack_system_name win32)
+  ENDIF(CMAKE_CL_64)
+ENDIF(${__cpack_system_name} MATCHES Windows)
+cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}")
+
 # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
 cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
-  "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}")
+  "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_SYSTEM_NAME}")
 cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
   "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
 cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
@@ -89,7 +99,7 @@ ENDIF(NOT CPACK_GENERATOR)
 cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
   "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
 cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
-cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CMAKE_SYSTEM_NAME}")
+cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
 
 cpack_encode_variables()
 CONFIGURE_FILE("${cpack_input_file}"
@@ -98,7 +108,7 @@ CONFIGURE_FILE("${cpack_input_file}"
 # Generate source file
 cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES
   "${CMAKE_SOURCE_DIR};/")
-cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG "${CMAKE_SYSTEM_NAME}-Source")
+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_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-Source")
 cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
index bcee37fc7d..e93a144fbb 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/NSIS.template.in
@@ -134,6 +134,7 @@ Function AddToPath
     Goto AddToPath_done
  
   AddToPath_NT:
+    MessageBox MB_OK 'Add to path "$0"'
     ReadRegStr $1 SHCTX "Environment" "PATH"
     StrCpy $2 $1 1 -1 # copy last char
     StrCmp $2 ";" 0 +2 # if last char == ;
@@ -202,6 +203,7 @@ Function un.RemoveFromPath
       Goto unRemoveFromPath_done
  
   unRemoveFromPath_NT:
+    MessageBox MB_OK 'Remove from path "$0"'
     ReadRegStr $1 SHCTX "Environment" "PATH"
     StrCpy $5 $1 1 -1 # copy last char
     StrCmp $5 ";" +2 # if last char != ;
-- 
GitLab