From fec32328b17662d44bfa7769e672529c24e1697f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 6 Jan 2011 12:35:48 +0000 Subject: [PATCH 1/3] Allow NSIS package or uninstall icon (#11143) Previously both CPACK_NSIS_MUI_ICON and CPACK_NSIS_MUI_UNIICON needed to be set for either to take effect. This commit allows either to be set rather than requiring both as users may well want to e.g. use a default uninstall icon but a custom install icon. --- Source/CPack/cmCPackNSISGenerator.cxx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index f25866c28..f3ebf30a5 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -129,14 +129,21 @@ int cmCPackNSISGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName << " to " << nsisFileName << std::endl); if(this->IsSet("CPACK_NSIS_MUI_ICON") - && this->IsSet("CPACK_NSIS_MUI_UNIICON")) + || this->IsSet("CPACK_NSIS_MUI_UNIICON")) { - std::string installerIconCode="!define MUI_ICON \""; - installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON"); - installerIconCode += "\"\n"; - installerIconCode += "!define MUI_UNICON \""; - installerIconCode += this->GetOption("CPACK_NSIS_MUI_UNIICON"); - installerIconCode += "\"\n"; + std::string installerIconCode; + if(this->IsSet("CPACK_NSIS_MUI_ICON")) + { + installerIconCode += "!define MUI_ICON \""; + installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON"); + installerIconCode += "\"\n"; + } + if(this->IsSet("CPACK_NSIS_MUI_UNIICON")) + { + installerIconCode += "!define MUI_UNICON \""; + installerIconCode += this->GetOption("CPACK_NSIS_MUI_UNIICON"); + installerIconCode += "\"\n"; + } this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE", installerIconCode.c_str()); } From 702c8f8ba79591744449244ed47a5181fdf68a63 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 6 Jan 2011 12:48:47 +0000 Subject: [PATCH 2/3] Add CPACK_NSIS_EXECUTABLES_DIRECTORY (#7828) NSIS installers default to assuming the executables exist in a directory named "bin" under the installation directory. As this isn't usual for Windows programs, the addition of this variable allows the customization of this directory and links still to be created correctly. --- Modules/CPack.cmake | 5 +++++ Source/CPack/cmCPackNSISGenerator.cxx | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 7033e314a..dc65b5a64 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -257,6 +257,11 @@ # CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to # uninstall start menu shortcuts. # +# CPACK_NSIS_EXECUTABLES_DIRECTORY - Creating NSIS start menu links +# assumes that they are in 'bin' unless this variable is set. +# For example, you would set this to 'exec' if your executables are +# in an exec directory. +# # The following variable is specific to installers build on Mac OS X # using PackageMaker: # diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index f3ebf30a5..d27ab0a73 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -421,10 +421,13 @@ int cmCPackNSISGenerator::InitializeInternal() return 0; } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin"); const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); const char* cpackPackageDeskTopLinks = this->GetOption("CPACK_CREATE_DESKTOP_LINKS"); + const char* cpackNsisExecutablesDirectory + = this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"); std::vector cpackPackageDesktopLinksVector; if(cpackPackageDeskTopLinks) { @@ -472,7 +475,8 @@ int cmCPackNSISGenerator::InitializeInternal() ++ it; std::string linkName = *it; str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" - << linkName << ".lnk\" \"$INSTDIR\\bin\\" << execName << ".exe\"" + << linkName << ".lnk\" \"$INSTDIR\\" + << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\"" << std::endl; deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName << ".lnk\"" << std::endl; @@ -486,7 +490,8 @@ int cmCPackNSISGenerator::InitializeInternal() { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" - << linkName << ".lnk\" \"$INSTDIR\\bin\\" << execName << ".exe\"" + << linkName << ".lnk\" \"$INSTDIR\\" + << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\"" << std::endl; deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; deleteStr << " Delete \"$DESKTOP\\" << linkName From bee514c3611f7a7b972d9ade14f94c0f25bc001e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 6 Jan 2011 13:44:50 +0000 Subject: [PATCH 3/3] Add CPack NSIS MUI_FINISHPAGE_RUN support (#11144) MUI_FINISHPAGE_RUN is frequently used with NSIS and provides a checkbox on the finish page of an installer which specifies whether the specified executable should be run when the installer exits. This commit adds support for this setting in CPack. --- Modules/CPack.cmake | 3 +++ Modules/NSIS.template.in | 1 + Source/CPack/cmCPackNSISGenerator.cxx | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index dc65b5a64..5f9f05fe7 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -262,6 +262,9 @@ # For example, you would set this to 'exec' if your executables are # in an exec directory. # +# CPACK_NSIS_MUI_FINISHPAGE_RUN - Specify an executable to add an option +# to run on the finish page of the NSIS installer. +# # The following variable is specific to installers build on Mac OS X # using PackageMaker: # diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 776bc0718..ffe05158d 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -540,6 +540,7 @@ FunctionEnd @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ @CPACK_NSIS_INSTALLER_ICON_CODE@ @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ +@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@ ;-------------------------------- ;Pages diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index d27ab0a73..97885d5d6 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -156,6 +156,17 @@ int cmCPackNSISGenerator::PackageFiles() installerIconCode.c_str()); } + if(this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN")) + { + std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\"; + installerRunCode += this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"); + installerRunCode += "\\"; + installerRunCode += this->GetOption("CPACK_NSIS_MUI_FINISHPAGE_RUN"); + installerRunCode += "\"\n"; + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE", + installerRunCode.c_str()); + } + // Setup all of the component sections if (this->Components.empty()) {