From db4eb6fb919ffedb85d115e583e20606ab8925b0 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Tue, 12 May 2026 13:09:30 -0400 Subject: [PATCH] CMP0218: Clarify when policy applies Handling of `CMAKE_{WARN,ERROR}_DEPRECATED` in CMake 4.3 is truly atrocious; some places look at the non-cache values, while others only care about the `cmMessenger` state (which is synchronized with the cache values of said variables). For CMP0218, we do not introduce any new instances of examining the non-cache values. Try to clarify the policy description to better state which historic diagnostics are affected, and which are not. --- Help/policy/CMP0218.rst | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Help/policy/CMP0218.rst b/Help/policy/CMP0218.rst index 2cba81c3ff..6e64d0c17b 100644 --- a/Help/policy/CMP0218.rst +++ b/Help/policy/CMP0218.rst @@ -7,7 +7,8 @@ The :variable:`CMAKE_WARN_DEPRECATED` and :variable:`CMAKE_ERROR_DEPRECATED` variables are ignored. In CMake 4.3 and below, these variables controlled whether deprecation messages -resulted in warnings, errors, or were suppressed. +resulted in warnings, errors, or were suppressed. However, not all deprecation +messages considered the non-cache values. CMake 4.4 introduced a new, unified system for managing :manual:`diagnostics ` that prefers the @@ -17,11 +18,21 @@ This policy provides compatibility with projects that relied on these variables and have not been updated to be aware of the change. The ``OLD`` behavior for this policy is to use the variables to control -deprecation messages which existed prior to CMake 4.4. +deprecation messages which respected the non-cache values of these variables +in CMake 4.3 and earlier. -The ``NEW`` behavior does not ascribe any special meaning to these variables -and uses the :diagnostic:`CMD_DEPRECATED` diagnostic state to control all -deprecation messages. +The ``NEW`` behavior does not ascribe any special meaning to the non-cache +values of these variables and uses the :diagnostic:`CMD_DEPRECATED` diagnostic +state to control all deprecation messages. + +.. note:: + + The :variable:`CMAKE_WARN_DEPRECATED` and :variable:`CMAKE_ERROR_DEPRECATED` + *cache* variables are synchronized with the initial state of the + :diagnostic:`CMD_DEPRECATED` diagnostic, regardless of this policy's setting. + (The synchronization happens at a point prior to when it is possible to + manipulate policies.) However, this behavior is deprecated and will be + removed in a future version of CMake. Any deprecation messages introduced in CMake 4.4 or later are controlled by the :diagnostic:`CMD_DEPRECATED` diagnostic regardless of the setting of this