From f4817032ec5764842feb19109e7e747d5b5b5f17 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 Jan 2016 16:23:48 -0800 Subject: [PATCH] make uninstaller name a cmake/cpack variable --- cmake/macros/SetPackagingParameters.cmake | 2 ++ cmake/templates/CPackProperties.cmake.in | 1 + cmake/templates/NSIS.template.in | 17 ++++++++--------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmake/macros/SetPackagingParameters.cmake b/cmake/macros/SetPackagingParameters.cmake index 503c57a619..78ba8f1a71 100644 --- a/cmake/macros/SetPackagingParameters.cmake +++ b/cmake/macros/SetPackagingParameters.cmake @@ -69,6 +69,8 @@ macro(SET_PACKAGING_PARAMETERS) message(FATAL_ERROR "Code signing of executables was requested but signtool.exe could not be found.") endif () endif () + + set(GENERATED_UNINSTALLER_EXEC_NAME "Uninstall.exe") endif () if (APPLE) diff --git a/cmake/templates/CPackProperties.cmake.in b/cmake/templates/CPackProperties.cmake.in index 0c645afe4a..0bfa179d5b 100644 --- a/cmake/templates/CPackProperties.cmake.in +++ b/cmake/templates/CPackProperties.cmake.in @@ -19,3 +19,4 @@ set(POST_INSTALL_OPTIONS_PATH "@POST_INSTALL_OPTIONS_PATH@") set(CLIENT_COMPONENT_NAME "@CLIENT_COMPONENT@") set(SERVER_COMPONENT_NAME "@SERVER_COMPONENT@") set(SIGNTOOL_EXECUTABLE "@SIGNTOOL_EXECUTABLE@") +set(UNINSTALLER_NAME "@GENERATED_UNINSTALLER_EXEC_NAME@") diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in index 39b3e28ecf..035cb1ebe0 100644 --- a/cmake/templates/NSIS.template.in +++ b/cmake/templates/NSIS.template.in @@ -6,7 +6,6 @@ !define VERSION "@CPACK_PACKAGE_VERSION@" !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@" !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" - !define UNINSTALLER_NAME "Uninstall.exe" ;-------------------------------- ;Variables @@ -68,7 +67,7 @@ ; The Inner invocation has written an uninstaller binary for us. ; We need to sign it if it's a production or PR build. !if @PRODUCTION_BUILD@ == 1 - !system '"@SIGNTOOL_EXECUTABLE@" sign /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com /td SHA256 $%TEMP%\$UNINSTALLER_NAME' = 0 + !system '"@SIGNTOOL_EXECUTABLE@" sign /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com /td SHA256 $%TEMP%\@UNINSTALLER_NAME@' = 0 !endif ; Good. Now we can carry on writing the real installer. @@ -690,7 +689,7 @@ Section "-Core installation" ;Package the signed uninstaller produced by the inner loop !ifndef INNER ; this packages the signed uninstaller - File $%TEMP%\$UNINSTALLER_NAME + File $%TEMP%\@UNINSTALLER_NAME@ !endif Push "DisplayName" @@ -703,7 +702,7 @@ Section "-Core installation" Push "@CPACK_PACKAGE_VENDOR@" Call ConditionalAddToRegisty Push "UninstallString" - Push "$INSTDIR\$UNINSTALLER_NAME" + Push "$INSTDIR\@UNINSTALLER_NAME@" Call ConditionalAddToRegisty Push "NoRepair" Push "1" @@ -762,7 +761,7 @@ Section "-Core installation" "$INSTDIR\@CONSOLE_WIN_EXEC_NAME@" ${EndIf} - CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\$UNINSTALLER_NAME" + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\@UNINSTALLER_NAME@" ;Read a value from an InstallOptions INI file !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" @@ -938,8 +937,8 @@ Function un.onInit ; so we move it to the $TEMP dir and then execute the copied uninstaller. ${If} $EXEDIR != $TEMP - CopyFiles /SILENT $EXEPATH $TEMP\$UNINSTALLER_NAME - ExecWait '"$Temp\$UNINSTALLER_NAME" _?=$INSTDIR' $0 + CopyFiles /SILENT $EXEPATH $TEMP\@UNINSTALLER_NAME@ + ExecWait '"$Temp\@UNINSTALLER_NAME@" _?=$INSTDIR' $0 SetErrorLevel $0 Quit ${EndIf} @@ -1061,7 +1060,7 @@ Section "Uninstall" !endif ;Remove the uninstaller itself. - Delete "$INSTDIR\$UNINSTALLER_NAME" + Delete "$INSTDIR\@UNINSTALLER_NAME@" DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" ;Remove the installation directory if it is empty. @@ -1147,7 +1146,7 @@ Function .onInit ; the installer. This is better than processing a command line option as it means ; this entire code path is not present in the final (real) installer. - WriteUninstaller "$%TEMP%\$UNINSTALLER_NAME" + WriteUninstaller "$%TEMP%\@UNINSTALLER_NAME@" ; just bail out quickly when running the "inner" installer Quit