diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst index f196988685..ae4f1e7c63 100644 --- a/Help/cpack_gen/wix.rst +++ b/Help/cpack_gen/wix.rst @@ -458,8 +458,7 @@ Windows using WiX. administrative privileges. Start menu entries created by the installer are visible to all users. - This is the default if :variable:`CPACK_WIX_VERSION` is set to any - value other than ``3``. + This is the default. See policy :policy:`CMP0172`. ``perUser`` Not yet supported. This is reserved for future use. @@ -467,9 +466,8 @@ Windows using WiX. ``NONE`` Create an installer without any ``InstallScope`` attribute. - If :variable:`CPACK_WIX_VERSION` is not set, or is set to ``3``, this - value is the default to preserve compatibility with 3.28 and lower. - Otherwise, this value is not supported. + This is supported only if :variable:`CPACK_WIX_VERSION` is not set, + or is set to ``3``. .. deprecated:: 3.29 diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 90c71b70d4..92953fdc76 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.31 .. toctree:: :maxdepth: 1 + CMP0172: The CPack module enables per-machine installation by default in the CPack WIX Generator. CMP0171: 'codegen' is a reserved target name. Policies Introduced by CMake 3.30 diff --git a/Help/policy/CMP0172.rst b/Help/policy/CMP0172.rst new file mode 100644 index 0000000000..c316975792 --- /dev/null +++ b/Help/policy/CMP0172.rst @@ -0,0 +1,39 @@ +CMP0172 +------- + +.. versionadded:: 3.31 + +The :module:`CPack` module enables per-machine installation by default +in the :cpack_gen:`CPack WIX Generator`. + +The :cpack_gen:`CPack WIX Generator`'s :variable:`CPACK_WIX_INSTALL_SCOPE` +option controls the scope of the generated Windows Installer package. +When :variable:`CPACK_WIX_VERSION` is set to 4 or higher, the default scope +is ``perMachine``. However, when using WIX 3 the default scope is ``NONE``, +and CPack does not set any ``InstallScope`` in the package specification. +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. + +The :module:`CPack` module in CMake 3.30 and older does not specify any +:variable:`CPACK_WIX_INSTALL_SCOPE` value by default, so CPack uses no +installation scope by default with WIX 3. CMake 3.31 and newer instead +prefer to set :variable:`CPACK_WIX_INSTALL_SCOPE` to ``perMachine`` by +default to make the behavior consistent across all WIX versions. This +policy provides compatibility for projects that have not been updated +to expect ``perMachine`` behavior. + +The ``OLD`` behavior for this policy is to not set +:variable:`CPACK_WIX_INSTALL_SCOPE` by default. The ``NEW`` behavior for +this policy is to set :variable:`CPACK_WIX_INSTALL_SCOPE` to ``perMachine`` +by default. + +.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.31 +.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default +.. include:: STANDARD_ADVICE.txt + +See documentation of the +:variable:`CMAKE_POLICY_WARNING_CMP0172 >` +variable to control the warning. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/cpack-wix-per-machine.rst b/Help/release/dev/cpack-wix-per-machine.rst new file mode 100644 index 0000000000..b62cf63b20 --- /dev/null +++ b/Help/release/dev/cpack-wix-per-machine.rst @@ -0,0 +1,6 @@ +cpack-wix-per-machine +--------------------- + +* The :module:`CPack` module enables per-machine installation by default + in the :cpack_gen:`CPack WIX Generator`. See policy :policy:`CMP0172` + and the :variable:`CPACK_WIX_INSTALL_SCOPE` variable. diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index f844105e43..59fa0be530 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -38,6 +38,8 @@ only for the policies that do not warn by default: policy :policy:`CMP0129`. * ``CMAKE_POLICY_WARNING_CMP0133`` controls the warning for policy :policy:`CMP0133`. +* ``CMAKE_POLICY_WARNING_CMP0172`` controls the warning for + policy :policy:`CMP0172`. This variable should not be set by a project in CMake code. Project developers running CMake may set this variable in their cache to diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index ed9a7a5f59..3afe08266d 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -885,6 +885,20 @@ endif() # WiX specific variables _cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}") +if(NOT DEFINED CPACK_WIX_INSTALL_SCOPE) + cmake_policy(GET CMP0172 _CPack_CMP0172) + if("x${_CPack_CMP0172}x" STREQUAL "xNEWx") + _cpack_set_default(CPACK_WIX_INSTALL_SCOPE perMachine) + elseif(NOT "x${_CPack_CMP0172}x" STREQUAL "xOLDx" AND CMAKE_POLICY_WARNING_CMP0172) + cmake_policy(GET_WARNING CMP0172 _CMP0172_warning) + message(AUTHOR_WARNING + "${_CMP0172_warning}\n" + "For compatibility, CMake will not enable per-machine installation by default in the CPack WIX Generator." + ) + unset(_CMP0172_warning) + endif() + unset(_CPack_CMP0172) +endif() # productbuild specific variables cmake_policy(GET CMP0161 _CPack_CMP0161) diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 85f3293e95..c76a88a392 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -527,7 +527,11 @@ class cmMakefile; "FETCHCONTENT_FULLY_DISCONNECTED requirements are enforced.", 3, 30, \ 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0171, "'codegen' is a reserved target name.", 3, 31, 0, \ - cmPolicies::WARN) + cmPolicies::WARN) \ + SELECT(POLICY, CMP0172, \ + "The CPack module enables per-machine installation by default in " \ + "the CPack WIX Generator.", \ + 3, 31, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Tests/RunCMake/CPackConfig/CMP0172-NEW-check.cmake b/Tests/RunCMake/CPackConfig/CMP0172-NEW-check.cmake new file mode 100644 index 0000000000..3e26e53aed --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-NEW-check.cmake @@ -0,0 +1,2 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) +test_variable(CPACK_WIX_INSTALL_SCOPE "perMachine") diff --git a/Tests/RunCMake/CPackConfig/CMP0172-NEW.cmake b/Tests/RunCMake/CPackConfig/CMP0172-NEW.cmake new file mode 100644 index 0000000000..ddab22769e --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-NEW.cmake @@ -0,0 +1 @@ +cmake_policy(SET CMP0172 NEW) diff --git a/Tests/RunCMake/CPackConfig/CMP0172-OLD-check.cmake b/Tests/RunCMake/CPackConfig/CMP0172-OLD-check.cmake new file mode 100644 index 0000000000..63889b4c44 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-OLD-check.cmake @@ -0,0 +1,2 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) +test_variable(CPACK_WIX_INSTALL_SCOPE "") diff --git a/Tests/RunCMake/CPackConfig/CMP0172-OLD.cmake b/Tests/RunCMake/CPackConfig/CMP0172-OLD.cmake new file mode 100644 index 0000000000..856c9e7d99 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-OLD.cmake @@ -0,0 +1,2 @@ +set(CMAKE_POLICY_WARNING_CMP0172 1) +cmake_policy(SET CMP0172 OLD) diff --git a/Tests/RunCMake/CPackConfig/CMP0172-WARN-check.cmake b/Tests/RunCMake/CPackConfig/CMP0172-WARN-check.cmake new file mode 100644 index 0000000000..63889b4c44 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-WARN-check.cmake @@ -0,0 +1,2 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) +test_variable(CPACK_WIX_INSTALL_SCOPE "") diff --git a/Tests/RunCMake/CPackConfig/CMP0172-WARN-stderr.txt b/Tests/RunCMake/CPackConfig/CMP0172-WARN-stderr.txt new file mode 100644 index 0000000000..4596686abf --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-WARN-stderr.txt @@ -0,0 +1,12 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/CPack\.cmake:[0-9]+ \(message\): + Policy CMP0172 is not set: The CPack module enables per-machine + installation by default in the CPack WIX Generator\. Run "cmake + --help-policy CMP0172" for policy details\. Use the cmake_policy command to + set the policy and suppress this warning. + + For compatibility, CMake will not enable per-machine installation by + default in the CPack WIX Generator\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/CPackConfig/CMP0172-WARN.cmake b/Tests/RunCMake/CPackConfig/CMP0172-WARN.cmake new file mode 100644 index 0000000000..d9c4f0acef --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0172-WARN.cmake @@ -0,0 +1 @@ +set(CMAKE_POLICY_WARNING_CMP0172 1) diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake index 1de640bd94..4d610731ab 100644 --- a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake @@ -5,6 +5,9 @@ run_cmake(CMP0133-WARN) run_cmake(CMP0161-NEW) run_cmake(CMP0161-OLD) run_cmake(CMP0161-WARN) +run_cmake(CMP0172-NEW) +run_cmake(CMP0172-OLD) +run_cmake(CMP0172-WARN) run_cmake(Simple) run_cmake(Default) run_cmake(Special)