diff options
author | Max Gaukler <development@maxgaukler.de> | 2023-11-07 21:02:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-11-16 19:15:38 (GMT) |
commit | 60661f67701d890b6c8200261953d01b66462158 (patch) | |
tree | 42c9b7ffe9d17c1f9db03915cc17d5016110aa02 | |
parent | f22ecbacb6824881e755b19f498607793e19969c (diff) | |
download | CMake-60661f67701d890b6c8200261953d01b66462158.zip CMake-60661f67701d890b6c8200261953d01b66462158.tar.gz CMake-60661f67701d890b6c8200261953d01b66462158.tar.bz2 |
CPack/WiX: Make InstallScope configurable
Add a new `CPACK_WIX_INSTALL_SCOPE` variable to set the `InstallScope`
when using the default WiX template. Set the default to the bug-free
value `perMachine`.
Fixes: #20962
-rw-r--r-- | Help/cpack_gen/wix.rst | 31 | ||||
-rw-r--r-- | Help/release/dev/wix-installscope.rst | 13 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackWIX.cmake | 4 | ||||
-rw-r--r-- | Modules/Internal/CPack/WIX.template.in | 5 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 1 |
5 files changed, 53 insertions, 1 deletions
diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst index af01252..cb56c9d 100644 --- a/Help/cpack_gen/wix.rst +++ b/Help/cpack_gen/wix.rst @@ -119,7 +119,8 @@ Windows using WiX. If this variable is set, the specified template will be used to generate the WiX wxs file. This should be used if further customization of the - output is required. + output is required. The template contents will override the effect of most + ``CPACK_WIX_`` variables. If this variable is not set, the default MSI template included with CMake will be used. @@ -337,3 +338,31 @@ Windows using WiX. of the installer. May for example be set to ``x64`` or ``arm64``. When unspecified, CPack will default to ``x64`` or ``x86``. + +.. variable:: CPACK_WIX_INSTALL_SCOPE + + .. versionadded:: 3.29 + + This variable can be optionally set to specify the ``InstallScope`` + of the installer: + + ``perMachine`` (default) + Create an installer that installs for all users and requires + administrative privileges. Start menu entries created by the + installer are visible to all users. + + ``perUser`` + Not yet supported. This is reserved for future use. + + ``NONE`` + Create an installer without any ``InstallScope`` attribute. + + .. deprecated:: 3.29 + + This value is only for compatibility with the inconsistent behavior used + by CPack 3.28 and older. The resulting installer requires administrative + privileges and installs into the system-wide ``ProgramFiles`` directory, + but the start menu entry and uninstaller registration are created only + for the current user. + + See https://wixtoolset.org/docs/v3/xsd/wix/package/ diff --git a/Help/release/dev/wix-installscope.rst b/Help/release/dev/wix-installscope.rst new file mode 100644 index 0000000..1978698 --- /dev/null +++ b/Help/release/dev/wix-installscope.rst @@ -0,0 +1,13 @@ +wix-installscope +---------------- + +* The :cpack_gen:`CPack WIX Generator` gained a new variable, + :variable:`CPACK_WIX_INSTALL_SCOPE`, to control the + ``InstallScope`` property of WiX MSI installers. + +* The :cpack_gen:`CPack WIX Generator` now produces WiX MSI installers + that create start menu and uninstall entries for all users by default, + as documented by the :variable:`CPACK_WIX_INSTALL_SCOPE` variable + ``perMachine`` value. Previously, without a custom WiX template, + it produced installers that would only create start menu and uninstall + entries for the current user, even though they install for all users. diff --git a/Modules/Internal/CPack/CPackWIX.cmake b/Modules/Internal/CPack/CPackWIX.cmake index d1875f2..5fe772e 100644 --- a/Modules/Internal/CPack/CPackWIX.cmake +++ b/Modules/Internal/CPack/CPackWIX.cmake @@ -18,3 +18,7 @@ find_program(CPACK_WIX_LIGHT_EXECUTABLE light if(NOT CPACK_WIX_LIGHT_EXECUTABLE) message(FATAL_ERROR "Could not find the WiX light executable.") endif() + +if(NOT DEFINED CPACK_WIX_INSTALL_SCOPE) + set(CPACK_WIX_INSTALL_SCOPE "perMachine") +endif() diff --git a/Modules/Internal/CPack/WIX.template.in b/Modules/Internal/CPack/WIX.template.in index c0bf935..fdd8278 100644 --- a/Modules/Internal/CPack/WIX.template.in +++ b/Modules/Internal/CPack/WIX.template.in @@ -12,7 +12,12 @@ Manufacturer="$(var.CPACK_PACKAGE_VENDOR)" UpgradeCode="$(var.CPACK_WIX_UPGRADE_GUID)"> + + <?if $(var.CPACK_WIX_INSTALL_SCOPE) = "NONE" ?> <Package InstallerVersion="301" Compressed="yes"/> + <?else?> + <Package InstallerVersion="301" Compressed="yes" InstallScope="$(var.CPACK_WIX_INSTALL_SCOPE)"/> + <?endif?> <Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/> diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 5077596..6918b5e 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -359,6 +359,7 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() GetOption("CPACK_PACKAGE_NAME")); CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER"); CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); + CopyDefinition(includeFile, "CPACK_WIX_INSTALL_SCOPE"); } void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() |