CMake.nsi.in 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. ; CMake install script designed for a nmake build
  2. ;--------------------------------
  3. ; You must define these values
  4. !define VERSION "@CMake_VERSION@"
  5. !define PATCH "@CMake_VERSION_PATCH@"
  6. !define INST_DIR "@CMake_INSTALL_TOP@"
  7. ;--------------------------------
  8. ;Variables
  9. Var MUI_TEMP
  10. Var STARTMENU_FOLDER
  11. ;--------------------------------
  12. ;Include Modern UI
  13. !include "MUI.nsh"
  14. ;Default installation folder
  15. InstallDir "$PROGRAMFILES\CMake ${VERSION}"
  16. ;--------------------------------
  17. ; determine admin versus local install
  18. Function .onInit
  19. ClearErrors
  20. UserInfo::GetName
  21. IfErrors noLM
  22. Pop $0
  23. UserInfo::GetAccountType
  24. Pop $1
  25. StrCmp $1 "Admin" 0 +3
  26. SetShellVarContext all
  27. ;MessageBox MB_OK 'User "$0" is in the Admin group'
  28. Goto done
  29. StrCmp $1 "Power" 0 +3
  30. SetShellVarContext all
  31. ;MessageBox MB_OK 'User "$0" is in the Power Users group'
  32. Goto done
  33. noLM:
  34. ;Get installation folder from registry if available
  35. done:
  36. FunctionEnd
  37. ;--------------------------------
  38. ;General
  39. ;Name and file
  40. Name "CMake ${VERSION}"
  41. OutFile "@PROJECT_BINARY_DIR@\cmake-${VERSION}.${PATCH}-win32.exe"
  42. ;--------------------------------
  43. ;Interface Settings
  44. !define MUI_HEADERIMAGE
  45. !define MUI_ABORTWARNING
  46. ;--------------------------------
  47. ; Define some macro setting for the gui
  48. !define MUI_HEADERIMAGE_BITMAP "@PROJECT_SOURCE_DIR@\Utilities\Release\@[email protected]"
  49. ;--------------------------------
  50. ;Pages
  51. !insertmacro MUI_PAGE_DIRECTORY
  52. ;Start Menu Folder Page Configuration
  53. !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
  54. !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Kitware\CMake ${VERSION}"
  55. !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
  56. !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
  57. !insertmacro MUI_PAGE_INSTFILES
  58. !insertmacro MUI_UNPAGE_CONFIRM
  59. !insertmacro MUI_UNPAGE_INSTFILES
  60. ;--------------------------------
  61. ;Languages
  62. !insertmacro MUI_LANGUAGE "English"
  63. ;--------------------------------
  64. ;Installer Sections
  65. Section "Dummy Section" SecDummy
  66. ;Use the entire tree produced by the INSTALL target. Keep the
  67. ;list of directories here in sync with the RMDir commands below.
  68. SetOutPath "$INSTDIR"
  69. File /r "${INST_DIR}\bin"
  70. File /r "${INST_DIR}\doc"
  71. File /r "${INST_DIR}\share"
  72. @NSIS_EXTRA_COMMANDS@
  73. ;Store installation folder
  74. WriteRegStr SHCTX "Software\Kitware\CMake ${VERSION}" "" $INSTDIR
  75. ;Create uninstaller
  76. WriteUninstaller "$INSTDIR\Uninstall.exe"
  77. !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  78. ;Create shortcuts
  79. CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
  80. CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\cmake.lnk" "$INSTDIR\bin\CMakeSetup.exe"
  81. CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  82. !insertmacro MUI_STARTMENU_WRITE_END
  83. SectionEnd
  84. ;--------------------------------
  85. ; determine admin versus local install
  86. Function un.onInit
  87. ClearErrors
  88. UserInfo::GetName
  89. IfErrors noLM
  90. Pop $0
  91. UserInfo::GetAccountType
  92. Pop $1
  93. StrCmp $1 "Admin" 0 +3
  94. SetShellVarContext all
  95. ;MessageBox MB_OK 'User "$0" is in the Admin group'
  96. Goto done
  97. StrCmp $1 "Power" 0 +3
  98. SetShellVarContext all
  99. ;MessageBox MB_OK 'User "$0" is in the Power Users group'
  100. Goto done
  101. noLM:
  102. ;Get installation folder from registry if available
  103. done:
  104. FunctionEnd
  105. ;--------------------------------
  106. ;Uninstaller Section
  107. Section "Uninstall"
  108. ;Remove directories we installed.
  109. ;Keep the list of directories here in sync with the File commands above.
  110. RMDir /r "$INSTDIR\bin"
  111. RMDir /r "$INSTDIR\doc"
  112. RMDir /r "$INSTDIR\share"
  113. ;Remove the uninstaller itself.
  114. Delete "$INSTDIR\Uninstall.exe"
  115. ;Remove the installation directory if it is empty.
  116. RMDir "$INSTDIR"
  117. ; Remove the registry entries.
  118. DeleteRegKey SHCTX "Software\Kitware\CMake ${VERSION}"
  119. !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
  120. Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
  121. Delete "$SMPROGRAMS\$MUI_TEMP\cmake.lnk"
  122. ;Delete empty start menu parent diretories
  123. StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
  124. startMenuDeleteLoop:
  125. ClearErrors
  126. RMDir $MUI_TEMP
  127. GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
  128. IfErrors startMenuDeleteLoopDone
  129. StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
  130. startMenuDeleteLoopDone:
  131. DeleteRegKey /ifempty SHCTX "Software\Kitware\CMake ${VERSION}"
  132. SectionEnd