CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL with CPackWix does not work
I'm trying to use CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL to uninstall a prior installation (same upgrade GUID), but haven't been able to get a message box asking the user to uninstall. Here is the relevant part of the top-level CMakeLists.txt
if(WIN32)
set(CPACK_WIX_UPGRADE_GUID "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
# GUID of 1.8
set(CPACK_WIX_PRODUCT_GUID "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXY")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules)
set(CPACK_WIX_LICENSE_RTF "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE_TOOL.RTF")
set(CPACK_PACKAGE_FILE_NAME "Tool_${STR_TXT}_Win64")
set(CPACK_PACKAGE_EXECUTABLES "tool;Tool")
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/gui/ToolLogoSymphony.ico")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Tool")
# all packages should have a descriptive root
set(TOOL_PACKAGE_ROOT .)
...
The problem I see is when I keep the CPACK_WIX_PRODUCT_GUID the same as the previous installation, the installer rightfully exits. But, I was hoping the CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL would first prompt for uninstallation before that. Putting a new CPACK_WIX_PRODUCT_GUID, the installer goes ahead and creates an overlapping installation of both versions, which is bad.
Edited by Iman