summaryrefslogtreecommitdiffstats
path: root/Modules/NSIS.template.in
diff options
context:
space:
mode:
authorPatrick Gansterer <paroga@paroga.com>2011-06-11 10:14:56 (GMT)
committerDavid Cole <david.cole@kitware.com>2012-04-22 15:30:34 (GMT)
commitfe58b67e24d007cb7dcd7005073a37bfba21737d (patch)
treea09e2ca15da6b9a9df2af6f57efd747eb72f6413 /Modules/NSIS.template.in
parent3a503926018fd10ef2120e2c1b98e93afb4fd0c1 (diff)
downloadCMake-fe58b67e24d007cb7dcd7005073a37bfba21737d.zip
CMake-fe58b67e24d007cb7dcd7005073a37bfba21737d.tar.gz
CMake-fe58b67e24d007cb7dcd7005073a37bfba21737d.tar.bz2
Added CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL
If CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL is set to ON the NSIS installer will look for a previous installed version and ask the user about uninstall.
Diffstat (limited to 'Modules/NSIS.template.in')
-rw-r--r--Modules/NSIS.template.in22
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
index 819cc5c..d4f5964 100644
--- a/Modules/NSIS.template.in
+++ b/Modules/NSIS.template.in
@@ -899,6 +899,28 @@ SectionEnd
; "Program Files" for AllUsers, "My Documents" for JustMe...
Function .onInit
+ StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
+
+ ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "UninstallString"
+ StrCmp $0 "" inst
+
+ MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
+ "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
+ IDYES uninst IDNO inst
+ Abort
+
+;Run the uninstaller
+uninst:
+ ClearErrors
+ ExecWait '$0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
+
+ IfErrors uninst_failed inst
+uninst_failed:
+ MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
+ Abort
+
+
+inst:
; Reads components status for registry
!insertmacro SectionList "InitSection"