View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014397CMakeCPackpublic2013-09-10 17:522016-06-10 14:31
ReporterDavid Golub 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformMicrosoftOSWindowsOS Version7
Product VersionCMake 2.8.11.2 
Target VersionFixed in Version 
Summary0014397: CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL mixes settings from versions
DescriptionIn order for the CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL to work properly, it is necessary to use the same registry key for all versions, which causes a number of problems when installing multiple version of a product side-by-side. The simplest of these are that the newer version will be given a start menu folder named after the older version by default. Also, the older version's entry in Add/Remove Programs will be overwritten by the newer version. There is also one more issue, which can be reproduced using the following steps given two versions of a product, Version 1 and Version 2:

1. Install Version 1.
2. Install Version 2. When prompted to uninstall Version 1, do not do so. Change the start menu folder to be different from that used for Version 1.
3. Uninstall Version 1.

When Version 1 is uninstalled, the start menu folder for Version 2 will be removed, while the start menu folder for Version 1 will remain.
Additional InformationThe issue can be fixed by using a different registry key for each version installed and a separate registry key holding the name of the latest version installed, which will be uninstalled if the user elects to do so when a new version is installed. While I have not tried to integrate our fix into CPack's template, I am providing the code that we are using at Organic Motion to work around the issue for our products:

  # In theory, prompting to uninstall an old version before installing a new
  # one should be as simple as setting CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL.
  # However, in practice, the implementation of this option in CMake is very
  # buggy and causes settings from the two versions to get mixed. Instead, we
  # manually add a modified version of the logic used to implement this option.
  # Our version differs from that provided with CMake in that it stores the
  # uninstallation information for each version in a separate registry key and
  # then uses a separate registry key to store the name of the last version
  # installed for each product. The version provided with CMake uses a single
  # registry key for each product, causing the settings to get mixed.
  if(OM_PROMPT_UNINSTALL)
    set(OM_EXTRA_INIT_COMMANDS "ReadRegStr $0 HKLM \\\"Software\\\\Organic Motion\\\\${OM_PRODUCT_NAME}\\\" \\\"LastVersionName\\\"
StrCmp $0 \\\"\\\" not_found
ReadRegStr $1 HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\$0\\\" \\\"UninstallString\\\"
StrCmp $1 \\\"\\\" not_found
ReadRegStr $2 HKLM \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\$0\\\" \\\"DisplayName\\\"
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \\\"$2 is already installed.$\\\\n$\\\\nDo you want to uninstall the old version before installing the new one?\\\" IDYES found IDNO not_found
Abort
found:
ClearErrors
StrLen $3 \\\"\\\\Uninstall.exe\\\"
StrCpy $4 $1 -$3
ExecWait '$1 _?=$4'
IfErrors 0 not_found
MessageBox MB_OK|MB_ICONSTOP \\\"Uninstall failed.\\\"
Abort
not_found:
${OM_EXTRA_INIT_COMMANDS}")
    set(OM_EXTRA_INSTALL_COMMANDS "WriteRegStr HKLM \\\"Software\\\\Organic Motion\\\\${OM_PRODUCT_NAME}\\\" \\\"LastVersionName\\\" \\\"${OM_PRODUCT_NAME} ${OM_VERSION}\\\"
${OM_EXTRA_INSTALL_COMMANDS}")
  endif(OM_PROMPT_UNINSTALL)
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0042361)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-09-10 17:52 David Golub New Issue
2016-06-10 14:29 Kitware Robot Note Added: 0042361
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team