diff options
author | Brad King <brad.king@kitware.com> | 2024-03-27 14:23:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-03-29 13:32:27 (GMT) |
commit | 32388821e2fedfdfbe080897697c5f6d16357321 (patch) | |
tree | 6861e20b703dd28b73e161ae9e00781d7c892df7 /Utilities/Release | |
parent | 8ffe1fd22c4da18f1e1f3f7f0210b675db1f888e (diff) | |
download | CMake-32388821e2fedfdfbe080897697c5f6d16357321.zip CMake-32388821e2fedfdfbe080897697c5f6d16357321.tar.gz CMake-32388821e2fedfdfbe080897697c5f6d16357321.tar.bz2 |
Utilities/Release/WiX: Save PATH modification preference persistently
Our Windows installer provides an interactive dialog to choose whether
the PATH should be modified. It may also be specified on the `msiexec`
command-line as an `ADD_CMAKE_TO_PATH={0,1}` property. Save the choice
persistently in the Windows Registry and use the same choice by default
in future installations.
Issue: #21465
Diffstat (limited to 'Utilities/Release')
-rw-r--r-- | Utilities/Release/WiX/WIX.template.in | 1 | ||||
-rw-r--r-- | Utilities/Release/WiX/options.wxs | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/Utilities/Release/WiX/WIX.template.in b/Utilities/Release/WiX/WIX.template.in index f48f782..fb8fa59 100644 --- a/Utilities/Release/WiX/WIX.template.in +++ b/Utilities/Release/WiX/WIX.template.in @@ -46,6 +46,7 @@ <FeatureRef Id="ProductFeature"> <ComponentRef Id="CMakeRegistry_InstallDir" /> + <ComponentRef Id="CMakeRegistry_InstallInPATH" /> </FeatureRef> <UIRef Id="$(var.CPACK_WIX_UI_REF)" /> diff --git a/Utilities/Release/WiX/options.wxs b/Utilities/Release/WiX/options.wxs index 2c76bb7..c274d85 100644 --- a/Utilities/Release/WiX/options.wxs +++ b/Utilities/Release/WiX/options.wxs @@ -6,13 +6,31 @@ <!-- Always initialize the checkbox value so it cannot be directly overridden from the command line. --> <SetProperty Action="Set_CMAKE_IN_PATH_Init" Id="CMAKE_IN_PATH" After="AppSearch" Sequence="first" Value="{}" /> + <!-- Read the "CMAKE_IN_PATH" checkbox value from the registry, if it was stored previously. + Properties using RegistrySearch cannot be private, so use a private-looking public name. --> + <Property Id="_CMAKE_IN_PATH_REG"> + <RegistrySearch Id="CMAKE_IN_PATH_RegistrySearch_HKLM" Root="HKLM" Key="Software\Kitware\CMake" Name="InstallInPATH" Type="raw" /> + </Property> + + <!-- Override the default "CMAKE_IN_PATH" checkbox with a value read from the registry, if any. --> + <SetProperty Action="Set_CMAKE_IN_PATH_REG_0" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_Init" Sequence="first" Value="{}"> _CMAKE_IN_PATH_REG = "#0" </SetProperty> + <SetProperty Action="Set_CMAKE_IN_PATH_REG_1" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_REG_0" Sequence="first" Value="1"> _CMAKE_IN_PATH_REG = "#1" </SetProperty> + <!-- Override the default "CMAKE_IN_PATH" checkbox with a value specified on the command line, if any. --> - <SetProperty Action="Set_CMAKE_IN_PATH_CMD_0" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_Init" Sequence="first" Value="{}"> ADD_CMAKE_TO_PATH = "0" </SetProperty> + <SetProperty Action="Set_CMAKE_IN_PATH_CMD_0" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_REG_1" Sequence="first" Value="{}"> ADD_CMAKE_TO_PATH = "0" </SetProperty> <SetProperty Action="Set_CMAKE_IN_PATH_CMD_1" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_CMD_0" Sequence="first" Value="1"> ADD_CMAKE_TO_PATH = "1" </SetProperty> <!-- Support legacy values too. --> <SetProperty Action="Set_CMAKE_IN_PATH_CMD_None" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_CMD_1" Sequence="first" Value="{}"> ADD_CMAKE_TO_PATH = "None" </SetProperty> <SetProperty Action="Set_CMAKE_IN_PATH_CMD_System" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_CMD_None" Sequence="first" Value="1"> ADD_CMAKE_TO_PATH = "System" AND ALLUSERS </SetProperty> <!-- Per-user installation is not implemented, but reserve the old value for future use. --> <SetProperty Action="Set_CMAKE_IN_PATH_CMD_User" Id="CMAKE_IN_PATH" After="Set_CMAKE_IN_PATH_CMD_System" Sequence="first" Value="1"> ADD_CMAKE_TO_PATH = "User" AND NOT ALLUSERS </SetProperty> + + <DirectoryRef Id="TARGETDIR"> + <!-- Save the "CMAKE_IN_PATH" checkbox value persistently in the registry. --> + <Component Id="CMakeRegistry_InstallInPATH"> + <!-- Use a leading "0" so the value parses as an integer even when the property is unset. --> + <RegistryValue Root="HKLM" Key="Software\Kitware\CMake" Name="InstallInPATH" Type="integer" Value="0[CMAKE_IN_PATH]" /> + </Component> + </DirectoryRef> </Fragment> </Wix> |