summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2006-04-30 14:59:20 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2006-04-30 14:59:20 (GMT)
commit35dc9190040ef4b60b0bc6b55b11d4bc77130ac0 (patch)
treeda7eba682ce8337dcd42509f63437dc45c593043 /Modules
parentdbcf3c792cbf9eb739a5d8fdfc97382937eb2352 (diff)
downloadCMake-35dc9190040ef4b60b0bc6b55b11d4bc77130ac0.zip
CMake-35dc9190040ef4b60b0bc6b55b11d4bc77130ac0.tar.gz
CMake-35dc9190040ef4b60b0bc6b55b11d4bc77130ac0.tar.bz2
ENH: move files from main tree to 2.4.1
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CPack.cmake2
-rw-r--r--Modules/NSIS.InstallOptions.ini.in29
-rw-r--r--Modules/NSIS.template.in154
3 files changed, 167 insertions, 18 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index 25785a0..d5e9b41 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -101,6 +101,8 @@ cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
+cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "@CPACK_PACKAGE_INSTALL_DIRECTORY@")
+
cpack_encode_variables()
CONFIGURE_FILE("${cpack_input_file}"
"${CMAKE_BINARY_DIR}/CPackConfig.cmake" @ONLY IMMEDIATE)
diff --git a/Modules/NSIS.InstallOptions.ini.in b/Modules/NSIS.InstallOptions.ini.in
new file mode 100644
index 0000000..1472a51
--- /dev/null
+++ b/Modules/NSIS.InstallOptions.ini.in
@@ -0,0 +1,29 @@
+[Settings]
+NumFields=3
+
+[Field 1]
+Type=label
+Text=By default @CPACK_PACKAGE_INSTALL_DIRECTORY@ does not add its directory to the system PATH.
+Left=0
+Right=-1
+Top=0
+Bottom=20
+
+[Field 2]
+Type=checkbox
+Text=Check this option to add the path to the system PATH
+Left=0
+Right=-1
+Top=30
+Bottom=40
+State=0
+
+[Field 3]
+Type=checkbox
+Text=If administrator, add to the PATH for all users.
+Left=0
+Right=-1
+Top=40
+Bottom=50
+State=1
+
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
index 7d0e68a..b39a6df 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/NSIS.template.in
@@ -13,6 +13,9 @@
Var MUI_TEMP
Var STARTMENU_FOLDER
Var SV_ALLUSERS
+ Var START_MENU
+ Var ADD_TO_PATH
+ Var ADD_TO_PATH_ALL_USERS
;--------------------------------
;Include Modern UI
@@ -60,6 +63,10 @@ Function .onInit
done:
StrCmp $SV_ALLUSERS "AllUsers" 0 +2
StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
+
+ StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
+ !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
+ noOptionsPage:
FunctionEnd
;--------------------------------
@@ -95,12 +102,7 @@ FunctionEnd
;====================================================
!macro select_NT_profile UN
Function ${UN}select_NT_profile
- MessageBox MB_YESNO|MB_ICONQUESTION "Change the environment for all users? $\n\
-$\n\
-Saying no here will change the envrironment for the current user only. $\n\
-$\n\
-(Administrator permissions required for all users)" \
- IDNO environment_single
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
DetailPrint "Selected environment for all users"
Push "all"
Return
@@ -153,9 +155,13 @@ $\r$\n\
read_path_NT_current:
ReadRegStr $1 ${NT_current_env} "PATH"
read_path_NT_resume:
- StrCmp $1 "" AddToPath_NTdoIt
+ StrCmp $1 "" AddToPath_NoCurrentPath
StrCpy $2 "$0;$1"
Goto AddToPath_NTdoIt
+ AddToPath_NoCurrentPath:
+ DetailPrint "No current path, so just use $0"
+ StrCpy $2 $0
+ Goto AddToPath_NTdoIt
AddToPath_NTdoIt:
StrCmp $4 "current" write_path_NT_current
ClearErrors
@@ -176,7 +182,8 @@ Should I try for the current user?" \
Goto write_path_NT_failed
write_path_NT_resume:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
- DetailPrint "added path for user ($4), $0"
+ DetailPrint "Added path for user ($4), $0"
+ DetailPrint "New path is: $2"
write_path_NT_failed:
Pop $4
@@ -243,18 +250,32 @@ $\r$\n\
ReadRegStr $1 ${NT_current_env} "PATH"
un_read_path_NT_resume:
+ StrCpy $8 $0
Push $1
Push $0
Call un.StrStr ; Find $0 in $1
Pop $0 ; pos of our dir
IntCmp $0 -1 unRemoveFromPath_done
; else, it is in path
- StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
- IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
- IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
- StrLen $0 $1
- StrCpy $1 $1 $0 $2
- StrCpy $3 "$3$1"
+ StrLen $5 $1 ; Get the length of the original path
+ StrLen $6 $0 ; get the length of path without the first path
+ IntOp $5 $5 - $6
+ IntOp $5 $5 - 1
+ IntCmp $5 -1 unRemoveFromPath_nothingBefore
+ StrCpy $3 $1 $5 ; $3 now has the part of the path before our dir
+ Goto unRemoveFromPath_AfterBefore
+ unRemoveFromPath_nothingBefore:
+ StrCpy $3 ""
+ unRemoveFromPath_AfterBefore:
+ StrCpy $7 $0 "" $2 ; $3 now has the part of the path after our dir
+ StrCpy $3 "$3$7"
+
+ ; $3 now holds path, but there may be some stray semicolon at
+ ; beginning. Let's remove it
+ StrCpy $7 $3 1
+ StrCmp $7 ";" 0 unRemoveFromPath_NoTrailingSemiColon
+ StrCpy $3 $3 "" 1
+ unRemoveFromPath_NoTrailingSemiColon:
StrCmp $4 "current" un_write_path_NT_current
WriteRegExpandStr ${NT_all_env} "PATH" $3
@@ -263,6 +284,8 @@ $\r$\n\
WriteRegExpandStr ${NT_current_env} "PATH" $3
un_write_path_NT_resume:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+ DetailPrint "Removed $8 from the path"
+ DetailPrint "New path is: $3"
unRemoveFromPath_done:
Pop $4
Pop $3
@@ -357,14 +380,31 @@ FunctionEnd
!insertmacro StrStr ""
!insertmacro StrStr "un."
+Function ConditionalAddToRegisty
+ Pop $0
+ Pop $1
+ StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
+ "$1" "$0"
+ ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
+ DetailPrint "Set install registry entry: '$1' to '$0'"
+ ConditionalAddToRegisty_EmptyString:
+FunctionEnd
+
;--------------------------------
; Define some macro setting for the gui
+ !define CPACK_PACKAGE_ICON@CPACK_PACKAGE_ICON@
+ !ifndef CPACK_PACKAGE_ICON
!define MUI_HEADERIMAGE_BITMAP "@CPACK_PACKAGE_ICON@"
+ !endif
;--------------------------------
;Pages
+ !insertmacro MUI_PAGE_WELCOME
+ !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
+ Page custom InstallOptionsPage
!insertmacro MUI_PAGE_DIRECTORY
;Start Menu Folder Page Configuration
@@ -384,12 +424,27 @@ FunctionEnd
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
+;Reserve Files
+
+ ;These files should be inserted before other files in the data block
+ ;Keep these lines before any File command
+ ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
+
+ ReserveFile "NSIS.InstallOptions.ini"
+ !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
+
+
+;--------------------------------
;Installer Sections
Section "Add to path"
Push $INSTDIR\bin
- StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 +2
+ ;Read a value from an InstallOptions INI file
+ !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
+ !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
+ StrCmp $ADD_TO_PATH "1" 0 doNotAddToPath
Call AddToPath
+ doNotAddToPath:
SectionEnd
Section "Installer Section" InstSection
@@ -405,10 +460,31 @@ Section "Installer Section" InstSection
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
- "DisplayName" "@CPACK_PACKAGE_INSTALL_DIRECTORY@ -- @CPACK_PACKAGE_DESCRIPTION_SUMMARY@"
+ "DisplayName" "@CPACK_NSIS_DISPLAY_NAME@"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
+ "DisplayVersion" "@CPACK_PACKAGE_VERSION@"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
+ "Publisher" "@CPACK_PACKAGE_VENDOR@"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
"UninstallString" "$INSTDIR\Uninstall.exe"
+ ; Optional registration
+ Push "DisplayIcon"
+ Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
+ Call ConditionalAddToRegisty
+ Push "HelpLink"
+ Push "@CPACK_NSIS_HELP_LINK@"
+ Call ConditionalAddToRegisty
+ Push "URLInfoAbout"
+ Push "@CPACK_NSIS_URL_INFO_ABOUT@"
+ Call ConditionalAddToRegisty
+ Push "Contact"
+ Push "@CPACK_NSIS_CONTACT@"
+ Call ConditionalAddToRegisty
+ Push "FooBar"
+ Push ""
+ Call ConditionalAddToRegisty
+
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
@@ -416,12 +492,26 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PAC
@CPACK_NSIS_CREATE_ICONS@
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
+ ; Write special uninstall registry entries
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
+ "StartMenu" "$STARTMENU_FOLDER"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
+ "AddToPath" "$ADD_TO_PATH"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
+ "AddToPathAllUsers" "$ADD_TO_PATH_ALL_USERS"
+
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
+;--------------------------------
+; Create custom pages
+Function InstallOptionsPage
+ !insertmacro MUI_HEADER_TEXT "Install Options" "Chose options for installing @CPACK_PACKAGE_INSTALL_DIRECTORY@"
+ !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
+FunctionEnd
;--------------------------------
; determine admin versus local install
@@ -452,6 +542,14 @@ FunctionEnd
;Uninstaller Section
Section "Uninstall"
+ ReadRegStr $START_MENU HKLM \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "StartMenu"
+ ;MessageBox MB_OK "Start menu is in: $START_MENU"
+ ReadRegStr $ADD_TO_PATH HKLM \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "AddToPath"
+ ReadRegStr $ADD_TO_PATH_ALL_USERS HKLM \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "AddToPathAllUsers"
+ ;MessageBox MB_OK "Add to path: $ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
@@ -485,14 +583,34 @@ Section "Uninstall"
IfErrors startMenuDeleteLoopDone
- StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
+ StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
+ ; If the user changed the shortcut, then untinstall may not work. This should
+ ; try to fix it.
+ StrCpy $MUI_TEMP "$START_MENU"
+ Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
+@CPACK_NSIS_DELETE_ICONS@
+
+ ;Delete empty start menu parent diretories
+ StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
+
+ secondStartMenuDeleteLoop:
+ ClearErrors
+ RMDir $MUI_TEMP
+ GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
+
+ IfErrors secondStartMenuDeleteLoopDone
+
+ StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
+ secondStartMenuDeleteLoopDone:
+
DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
Push $INSTDIR\bin
- StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 +2
+ StrCmp $ADD_TO_PATH "1" 0 doNotRemoveFromPath
Call un.RemoveFromPath
+ doNotRemoveFromPath:
SectionEnd