summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-11 22:02:38 (GMT)
committerBrad King <brad.king@kitware.com>2022-04-14 14:14:58 (GMT)
commitb760828d3fa50ae621d44ac00ffa77de5593c3ed (patch)
tree2f91a473dea3de8232166d78095e20516177e0bf
parentdd193fa3d357b7f1c2495348d58b85bb597844c5 (diff)
downloadCMake-b760828d3fa50ae621d44ac00ffa77de5593c3ed.zip
CMake-b760828d3fa50ae621d44ac00ffa77de5593c3ed.tar.gz
CMake-b760828d3fa50ae621d44ac00ffa77de5593c3ed.tar.bz2
CPack/DMG: Do not use CPACK_RESOURCE_FILE_LICENSE for SLA by default
Since macOS 12.0 deprecated the tools needed to attach a SLA to a `.dmg`, we should no longer do this by default. Add a policy to change the default to off. Fixes: #22978
-rw-r--r--Help/cpack_gen/dmg.rst4
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0133.rst32
-rw-r--r--Help/release/dev/cpack-dmg-sla.rst6
-rw-r--r--Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst2
-rw-r--r--Modules/CPack.cmake16
-rw-r--r--Source/cmPolicies.h6
-rw-r--r--Tests/RunCMake/CPackConfig/CMP0133-NEW-check.cmake3
-rw-r--r--Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake2
-rw-r--r--Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake3
-rw-r--r--Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt12
-rw-r--r--Tests/RunCMake/CPackConfig/CMP0133-WARN.cmake2
-rw-r--r--Tests/RunCMake/CPackConfig/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CPackConfig/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CPackConfig/SLA.txt4
15 files changed, 91 insertions, 6 deletions
diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst
index b4ef5a2..cba7a00 100644
--- a/Help/cpack_gen/dmg.rst
+++ b/Help/cpack_gen/dmg.rst
@@ -65,8 +65,8 @@ on macOS:
In a CMake project that uses the :module:`CPack` module to generate
``CPackConfig.cmake``, ``CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE``
- is automatically enabled by default if it is not set and
- :variable:`CPACK_RESOURCE_FILE_LICENSE` is set to a non-default value.
+ must be explicitly enabled by the project to activate the SLA.
+ See policy :policy:`CMP0133`.
.. note::
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 17a3764..84ef15f 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -58,6 +58,7 @@ Policies Introduced by CMake 3.24
.. toctree::
:maxdepth: 1
+ CMP0133: The CPack module disables SLA by default in the CPack DragNDrop Generator. </policy/CMP0133>
CMP0132: Do not set compiler environment variables on first run. </policy/CMP0132>
CMP0131: LINK_LIBRARIES supports the LINK_ONLY generator expression. </policy/CMP0131>
CMP0130: while() diagnoses condition evaluation errors. </policy/CMP0130>
diff --git a/Help/policy/CMP0133.rst b/Help/policy/CMP0133.rst
new file mode 100644
index 0000000..c19bcf9
--- /dev/null
+++ b/Help/policy/CMP0133.rst
@@ -0,0 +1,32 @@
+CMP0133
+-------
+
+.. versionadded:: 3.24
+
+The :module:`CPack` module disables SLA by default in the
+:cpack_gen:`CPack DragNDrop Generator`.
+
+The :cpack_gen:`CPack DragNDrop Generator` in CMake 3.22 and below attach a
+Software License Agreement (SLA) to ``.dmg`` files using the file specified
+by :variable:`CPACK_RESOURCE_FILE_LICENSE`, if set to a non-default value.
+macOS 12.0 deprecated the tools used to do this, so CMake 3.23 added
+the :variable:`CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE` option to
+control the behavior. CMake 3.23 enables that option by default for
+compatibility with older versions. CMake 3.24 and above prefer to *not*
+enable the :variable:`CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE` option by
+default. This policy provides compatibility with projects that have not
+been updated to account for the lack of a SLA in their ``.dmg`` packages.
+
+The ``OLD`` behavior for this policy is to enable
+:variable:`CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE` by default.
+The ``NEW`` behavior for this policy is to not enable it by default.
+
+This policy was introduced in CMake version 3.24. Use the
+:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW``
+explicitly. Unlike many policies, CMake version |release| does *not* warn
+by default when this policy is not set and simply uses ``OLD`` behavior.
+See documentation of the
+:variable:`CMAKE_POLICY_WARNING_CMP0133 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
+variable to control the warning.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/release/dev/cpack-dmg-sla.rst b/Help/release/dev/cpack-dmg-sla.rst
new file mode 100644
index 0000000..34c3cff
--- /dev/null
+++ b/Help/release/dev/cpack-dmg-sla.rst
@@ -0,0 +1,6 @@
+cpack-dmg-sla
+-------------
+
+* The :module:`CPack` module no longer enables the SLA by default in the
+ :cpack_gen:`CPack DragNDrop Generator`. See policy :policy:`CMP0133`
+ and the :variable:`CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE` variable.
diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
index 8c84f91..9dce760 100644
--- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
+++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
@@ -36,6 +36,8 @@ only for the policies that do not warn by default:
policy :policy:`CMP0128`.
* ``CMAKE_POLICY_WARNING_CMP0129`` controls the warning for
policy :policy:`CMP0129`.
+* ``CMAKE_POLICY_WARNING_CMP0133`` controls the warning for
+ policy :policy:`CMP0133`.
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 5a22be5..40cfde4 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -817,8 +817,20 @@ _cpack_set_default(CPACK_NSIS_INSTALLER_ICON_CODE "")
_cpack_set_default(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
# DragNDrop specific variables
-if(CPACK_RESOURCE_FILE_LICENSE AND NOT CPACK_RESOURCE_FILE_LICENSE STREQUAL "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
- _cpack_set_default(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE ON)
+if(NOT DEFINED CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE
+ AND CPACK_RESOURCE_FILE_LICENSE AND NOT CPACK_RESOURCE_FILE_LICENSE STREQUAL "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
+ cmake_policy(GET CMP0133 _CPack_CMP0133)
+ if(NOT "x${_CPack_CMP0133}x" STREQUAL "xNEWx")
+ if(NOT "x${_CPack_CMP0133}x" STREQUAL "xOLDx" AND CMAKE_POLICY_WARNING_CMP0133)
+ cmake_policy(GET_WARNING CMP0133 _CMP0133_warning)
+ message(AUTHOR_WARNING
+ "${_CMP0133_warning}\n"
+ "For compatibility, CMake will enable the SLA in the CPack DragNDrop Generator."
+ )
+ endif()
+ _cpack_set_default(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE ON)
+ endif()
+ unset(_CPack_CMP0133)
endif()
# WiX specific variables
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 434c51c..5393747 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -396,7 +396,11 @@ class cmMakefile;
24, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0132, \
"Do not set compiler environment variables on first run", 3, 24, 0, \
- cmPolicies::WARN)
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0133, \
+ "The CPack module disables SLA by default in the CPack DragNDrop " \
+ "Generator.", \
+ 3, 24, 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/CMP0133-NEW-check.cmake b/Tests/RunCMake/CPackConfig/CMP0133-NEW-check.cmake
new file mode 100644
index 0000000..c1ef0d1
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/CMP0133-NEW-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_variable(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE "")
diff --git a/Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake b/Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake
new file mode 100644
index 0000000..79c1a59
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake
@@ -0,0 +1,2 @@
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/SLA.txt")
+cmake_policy(SET CMP0133 NEW)
diff --git a/Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake b/Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake
new file mode 100644
index 0000000..01de980
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_variable(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE "ON")
diff --git a/Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt b/Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt
new file mode 100644
index 0000000..2858025
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Warning \(dev\) at [^
+]*/Modules/CPack.cmake:[0-9]+ \(message\):
+ Policy CMP0133 is not set: The CPack module disables SLA by default in the
+ CPack DragNDrop Generator. Run "cmake --help-policy CMP0133" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ For compatibility, CMake will enable the SLA in the CPack DragNDrop
+ 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/CMP0133-WARN.cmake b/Tests/RunCMake/CPackConfig/CMP0133-WARN.cmake
new file mode 100644
index 0000000..3f2208b
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/CMP0133-WARN.cmake
@@ -0,0 +1,2 @@
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/SLA.txt")
+set(CMAKE_POLICY_WARNING_CMP0133 1)
diff --git a/Tests/RunCMake/CPackConfig/CMakeLists.txt b/Tests/RunCMake/CPackConfig/CMakeLists.txt
index 9a9e7b4..1e071ec 100644
--- a/Tests/RunCMake/CPackConfig/CMakeLists.txt
+++ b/Tests/RunCMake/CPackConfig/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.3)
project(${RunCMake_TEST})
-include(${RunCMake_TEST}.cmake)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
include(CPack)
diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
index 8f2196d..32c7296 100644
--- a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
@@ -1,5 +1,7 @@
include(RunCMake)
+run_cmake(CMP0133-NEW)
+run_cmake(CMP0133-WARN)
run_cmake(Simple)
run_cmake(Default)
run_cmake(Special)
diff --git a/Tests/RunCMake/CPackConfig/SLA.txt b/Tests/RunCMake/CPackConfig/SLA.txt
new file mode 100644
index 0000000..94b19c3
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/SLA.txt
@@ -0,0 +1,4 @@
+Example License File
+--------------------
+
+This is an example license file for a DMG.