Commit fe58b67e authored by Patrick Gansterer's avatar Patrick Gansterer Committed by David Cole
Browse files

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.
parent 3a503926
...@@ -341,6 +341,10 @@ cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME ...@@ -341,6 +341,10 @@ cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME
cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}") cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
IF(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
SET(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
ENDIF(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
IF(CPACK_NSIS_MODIFY_PATH) IF(CPACK_NSIS_MODIFY_PATH)
SET(CPACK_NSIS_MODIFY_PATH ON) SET(CPACK_NSIS_MODIFY_PATH ON)
ENDIF(CPACK_NSIS_MODIFY_PATH) ENDIF(CPACK_NSIS_MODIFY_PATH)
......
...@@ -46,6 +46,14 @@ ...@@ -46,6 +46,14 @@
##end ##end
# #
##variable ##variable
# CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL - Ask about uninstalling
# previous versions first.
# If this is set to "ON", then an installer will look for previous
# installed versions and if one is found, ask the user whether to
# uninstall it before proceeding with the install.
##end
#
##variable
# CPACK_NSIS_MODIFY_PATH - Modify PATH toggle. # CPACK_NSIS_MODIFY_PATH - Modify PATH toggle.
# If this is set to "ON", then an extra page # If this is set to "ON", then an extra page
# will appear in the installer that will allow the user to choose # will appear in the installer that will allow the user to choose
......
...@@ -899,6 +899,28 @@ SectionEnd ...@@ -899,6 +899,28 @@ SectionEnd
; "Program Files" for AllUsers, "My Documents" for JustMe... ; "Program Files" for AllUsers, "My Documents" for JustMe...
Function .onInit 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 ; Reads components status for registry
!insertmacro SectionList "InitSection" !insertmacro SectionList "InitSection"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment