Utilities/Release/WiX: Convert PATH modification preference to checkbox

Add explicit support for passing a `ADD_CMAKE_TO_PATH={0,1}` property to
`msiexec` command-line installations to control the checkbox.  Also
preserve compatibility with the old `ADD_CMAKE_TO_PATH={None,System}`
property, which previously controlled the radio button group, by mapping
the values to the checkbox.

Remove the "Add CMake to the system PATH for the current user" option.
It actually added CMake to the installing user's PATH, not the system
PATH, even though CMake is installed to a system location.

Also revise the wording of the desktop shortcut checkbox to match
the style of the PATH checkbox wording.

Issue: #21465
stage/master/nightly/2024/03/29
Brad King 2024-03-27 10:13:41 -04:00
parent d320c76257
commit 7bd68cf381
4 changed files with 27 additions and 17 deletions

View File

@ -265,6 +265,7 @@ if("${CPACK_GENERATOR}" STREQUAL "WIX")
set(CPACK_WIX_EXTRA_SOURCES
"@CMake_SOURCE_DIR@/Utilities/Release/WiX/install_dir.wxs"
"@CMake_SOURCE_DIR@/Utilities/Release/WiX/options.wxs"
"@CMake_SOURCE_DIR@/Utilities/Release/WiX/options_dlg.wxs"
)

View File

@ -0,0 +1,18 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<!-- Hold the "CMAKE_IN_PATH" checkbox value in a public property to propagate to the InstallExecuteSequence. -->
<Property Id="CMAKE_IN_PATH" Value="Init" />
<!-- 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="{}" />
<!-- 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_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>
</Fragment>
</Wix>

View File

@ -1,7 +1,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Property Id="ADD_CMAKE_TO_PATH" Value="None"/>
<PropertyRef Id="CMAKE_IN_PATH" />
<Dialog Id="CMakeOptionsDlg" Width="370" Height="270" Title="Install Options">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)"/>
@ -17,18 +17,10 @@
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0"/>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0"/>
<Control Id="Hint" Type="Text" X="26" Y="60" Width="250" Height="16" Transparent="yes" Text="By default CMake does not add its directory to the system PATH."/>
<Control Id="ADD_CMAKE_TO_PATHOption" Type="RadioButtonGroup" X="26" Y="100" Width="305" Height="65" Property="ADD_CMAKE_TO_PATH">
<RadioButtonGroup Property="ADD_CMAKE_TO_PATH">
<RadioButton Value="None" X="0" Y="0" Width="295" Height="16" Text="Do not add CMake to the system PATH"/>
<RadioButton Value="System" X="0" Y="20" Width="295" Height="16" Text="Add CMake to the system PATH for all users"/>
<RadioButton Value="User" X="0" Y="40" Width="295" Height="16" Text="Add CMake to the system PATH for the current user"/>
</RadioButtonGroup>
</Control>
<Control Id="CMAKE_IN_PATH_CheckBox" Type="CheckBox" X="20" Y="60" Width="330" Height="18" CheckBoxValue="1" Property="CMAKE_IN_PATH" Text="Add CMake to the PATH environment variable" />
<?ifdef BUILD_QtDialog ?>
<Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="20" Y="170" Width="330" Height="18" CheckBoxValue="1" Property="DESKTOP_SHORTCUT_REQUESTED" Text="Create CMake Desktop Icon"/>
<Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="20" Y="80" Width="330" Height="18" CheckBoxValue="1" Property="DESKTOP_SHORTCUT_REQUESTED" Text="Add CMake shortcut to the Desktop" />
<?endif ?>
</Dialog>
</UI>

View File

@ -1,18 +1,17 @@
<CPackWiXPatch>
<CPackWiXFragment Id="CM_DP_bin">
<!-- Implement the "CMAKE_IN_PATH" checkbox when installing for all users. -->
<Component Id="CMakeSystemPathEntryCMP" KeyPath="yes" Guid="0E782367-5D68-4539-81D1-B9757AE496A1">
<Condition>ADD_CMAKE_TO_PATH = "System"</Condition>
<Condition>CMAKE_IN_PATH AND ALLUSERS</Condition>
<Environment Id="CMakeSystemPathEntryENV" Action="set" Part="last"
Name="PATH" Value="[INSTALL_ROOT]bin"
System="yes"/>
</Component>
<!-- Implement the "CMAKE_IN_PATH" checkbox when installing per-user. -->
<!-- This is not currently reachable, but is reserved for future use. -->
<Component Id="CMakeUserPathEntryCMP" KeyPath="yes" Guid="392E524D-D5BF-4F16-A7AF-A82B07482CB9">
<Condition>ADD_CMAKE_TO_PATH = "User"</Condition>
<Condition>CMAKE_IN_PATH AND NOT ALLUSERS</Condition>
<Environment Id="CMakeUserPathEntryENV" Action="set" Part="last"
Name="PATH" Value="[INSTALL_ROOT]bin"
System="no"/>