Merge topic 'doc-exe-result'

c720e2a23d Help: Document execute_process(RESULT_VARIABLE) capture in source code guide

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12028
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b391315..866390c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -429,6 +429,7 @@
     execute_process(COMMAND ${CMAKE_CXX_COMPILER}
       ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
       OUTPUT_VARIABLE _GXX_VERSION
+      RESULT_VARIABLE _GXX_VERSION_RESULT
     )
     string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
       _GXX_VERSION_SHORT ${_GXX_VERSION})
diff --git a/Help/command/message.rst b/Help/command/message.rst
index e8a4ea0..a25a5a6 100644
--- a/Help/command/message.rst
+++ b/Help/command/message.rst
@@ -44,12 +44,10 @@
   CMake Warning, continue processing.
 
 ``AUTHOR_WARNING``
-  CMake Warning (dev), continue processing.
+  CMake :diagnostic:`CMD_AUTHOR` diagnostic.
 
 ``DEPRECATION``
-  CMake Deprecation Error or Warning if variable
-  :variable:`CMAKE_ERROR_DEPRECATED` or :variable:`CMAKE_WARN_DEPRECATED`
-  is enabled, respectively, else no message.
+  CMake :diagnostic:`CMD_DEPRECATED` diagnostic.
 
 (none) or ``NOTICE``
   Important message printed to stderr to attract user's attention.
diff --git a/Help/diagnostic/CMD_DEPRECATED.rst b/Help/diagnostic/CMD_DEPRECATED.rst
index dfb23d5..85b9564 100644
--- a/Help/diagnostic/CMD_DEPRECATED.rst
+++ b/Help/diagnostic/CMD_DEPRECATED.rst
@@ -7,3 +7,11 @@
 
   Warn about use of a deprecated function or package.  This is the category
   triggered by :command:`message(DEPRECATION)`.
+
+  .. note::
+
+    If :policy:`CMP0218` is not set to ``NEW``, :command:`message(DEPRECATION)`
+    invocations, along with builtin deprecation messages that existed prior to
+    CMake 4.4, will ignore this diagnostic state and will instead use the
+    :variable:`CMAKE_WARN_DEPRECATED` and :variable:`CMAKE_ERROR_DEPRECATED`
+    variables to determine the severity of deprecation messages.
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 2ab7290..6728fee 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -100,6 +100,7 @@
 .. toctree::
    :maxdepth: 1
 
+   CMP0218: The CMAKE_WARN_DEPRECATED and CMAKE_ERROR_DEPRECATED variables are ignored. </policy/CMP0218>
    CMP0217: The MACROS directory property does not exist anymore. </policy/CMP0217>
    CMP0216: Swift targets have a default project name. </policy/CMP0216>
    CMP0215: Ninja generators emit Swift modules separately from compilation. </policy/CMP0215>
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 71318dd..9b9208f 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -224,7 +224,6 @@
    /variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS
    /variable/CMAKE_ECLIPSE_RESOURCE_ENCODING
    /variable/CMAKE_ECLIPSE_VERSION
-   /variable/CMAKE_ERROR_DEPRECATED
    /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
    /variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO
    /variable/CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL
@@ -318,7 +317,6 @@
    /variable/CMAKE_TLS_VERIFY
    /variable/CMAKE_TLS_VERSION
    /variable/CMAKE_USER_MAKE_RULES_OVERRIDE
-   /variable/CMAKE_WARN_DEPRECATED
    /variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
    /variable/CMAKE_XCODE_GENERATE_SCHEME
    /variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
@@ -878,8 +876,10 @@
 
    /variable/CMAKE_AUTOMOC_RELAXED_MODE
    /variable/CMAKE_BACKWARDS_COMPATIBILITY
+   /variable/CMAKE_ERROR_DEPRECATED
    /variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
    /variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
+   /variable/CMAKE_WARN_DEPRECATED
 
 Deprecated Variables that Describe the System
 =============================================
diff --git a/Help/policy/CMP0218.rst b/Help/policy/CMP0218.rst
new file mode 100644
index 0000000..2cba81c
--- /dev/null
+++ b/Help/policy/CMP0218.rst
@@ -0,0 +1,35 @@
+CMP0218
+-------
+
+.. versionadded:: 4.4
+
+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.
+
+CMake 4.4 introduced a new, unified system for managing
+:manual:`diagnostics <cmake-diagnostics(7)>` that prefers the
+:command:`cmake_diagnostic` command for manipulating diagnostic actions.
+
+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.
+
+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.
+
+Any deprecation messages introduced in CMake 4.4 or later are controlled by the
+:diagnostic:`CMD_DEPRECATED` diagnostic regardless of the setting of this
+policy.
+
+.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.4
+.. |WARNS_OR_DOES_NOT_WARN| replace::
+    warns when either variable is accessed or modified
+.. include:: include/STANDARD_ADVICE.rst
+
+.. include:: include/DEPRECATED.rst
diff --git a/Help/variable/CMAKE_ERROR_DEPRECATED.rst b/Help/variable/CMAKE_ERROR_DEPRECATED.rst
index 12aa50b..0bf7d55 100644
--- a/Help/variable/CMAKE_ERROR_DEPRECATED.rst
+++ b/Help/variable/CMAKE_ERROR_DEPRECATED.rst
@@ -5,5 +5,28 @@
 
 Whether to issue errors for deprecated functionality.
 
-If ``TRUE``, use of deprecated functionality will issue fatal errors.
-If this variable is not set, CMake behaves as if it were set to ``FALSE``.
+This is a deprecated mechanism for interacting with the
+:diagnostic:`CMD_DEPRECATED` :manual:`diagnostic <cmake-diagnostics(7)>`.
+If policy :policy:`CMP0218` is set to ``NEW``, this variable is ignored.
+
+If policy :policy:`CMP0218` is not set to ``NEW``, the :command:`message`
+command's ``DEPRECATION`` message type will use
+:variable:`CMAKE_WARN_DEPRECATED` and ``CMAKE_ERROR_DEPRECATED``
+to determine the severity of a deprecation diagnostic.  The severity will be:
+
+* ``IGNORE``, if ``CMAKE_WARN_DEPRECATED`` is ``OFF`` and
+  ``CMAKE_ERROR_DEPRECATED`` is unset or ``OFF``.
+
+* ``WARN``, if ``CMAKE_WARN_DEPRECATED`` is unset or ``ON`` and
+  ``CMAKE_ERROR_DEPRECATED`` is unset or ``OFF``.
+
+* ``FATAL_ERROR`` if ``CMAKE_ERROR_DEPRECATED`` is ``ON``.
+
+Setting ``CMAKE_ERROR_DEPRECATED`` in the cache will alter the default state of
+the :diagnostic:`CMD_DEPRECATED` :manual:`diagnostic <cmake-diagnostics(7)>`;
+however, the :option:`-W[no-][error=]deprecated <cmake -W>` option, and
+:preset:`warnings.deprecated <configurePresets.warnings.deprecated>` and/or
+:preset:`errors.deprecated <configurePresets.errors.deprecated>` preset
+fields, will take precedence. CMake will also update the cached value of
+``CMAKE_ERROR_DEPRECATED`` to reflect the actual state of the diagnostic as of
+the start of script execution.
diff --git a/Help/variable/CMAKE_WARN_DEPRECATED.rst b/Help/variable/CMAKE_WARN_DEPRECATED.rst
index ffe24bd..482b982 100644
--- a/Help/variable/CMAKE_WARN_DEPRECATED.rst
+++ b/Help/variable/CMAKE_WARN_DEPRECATED.rst
@@ -5,9 +5,28 @@
 
 Whether to issue warnings for deprecated functionality.
 
-If not ``FALSE``, use of deprecated functionality will issue warnings.
-If this variable is not set, CMake behaves as if it were set to ``TRUE``.
+This is a deprecated mechanism for interacting with the
+:diagnostic:`CMD_DEPRECATED` :manual:`diagnostic <cmake-diagnostics(7)>`.
+If policy :policy:`CMP0218` is set to ``NEW``, this variable is ignored.
 
-When running :manual:`cmake(1)`, this option can be enabled with the
-:option:`-Wdeprecated <cmake -W>` option, or disabled with the
-:option:`-Wno-deprecated <cmake -Wno->` option.
+If policy :policy:`CMP0218` is not set to ``NEW``, the :command:`message`
+command's ``DEPRECATION`` message type will use
+``CMAKE_WARN_DEPRECATED`` and :variable:`CMAKE_ERROR_DEPRECATED`
+to determine the severity of a deprecation diagnostic.  The severity will be:
+
+* ``IGNORE``, if ``CMAKE_WARN_DEPRECATED`` is ``OFF`` and
+  ``CMAKE_ERROR_DEPRECATED`` is unset or ``OFF``.
+
+* ``WARN``, if ``CMAKE_WARN_DEPRECATED`` is unset or ``ON`` and
+  ``CMAKE_ERROR_DEPRECATED`` is unset or ``OFF``.
+
+* ``FATAL_ERROR`` if ``CMAKE_ERROR_DEPRECATED`` is ``ON``.
+
+Setting ``CMAKE_WARN_DEPRECATED`` in the cache will alter the default state of
+the :diagnostic:`CMD_DEPRECATED` :manual:`diagnostic <cmake-diagnostics(7)>`;
+however, the :option:`-W[no-][error=]deprecated <cmake -W>` option, and
+:preset:`warnings.deprecated <configurePresets.warnings.deprecated>` and/or
+:preset:`errors.deprecated <configurePresets.errors.deprecated>` preset
+fields, will take precedence. CMake will also update the cached value of
+``CMAKE_WARN_DEPRECATED`` to reflect the actual state of the diagnostic as of
+the start of script execution.
diff --git a/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake b/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake
index f6389d6..234fb5f 100644
--- a/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake
+++ b/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake
@@ -41,7 +41,8 @@
     set(${file_exists} "")
     execute_process(
       COMMAND ${adb_executable} shell ls ${device_file}
-      OUTPUT_VARIABLE out_var ERROR_VARIABLE out_var)
+      OUTPUT_VARIABLE out_var ERROR_VARIABLE out_var
+      RESULT_VARIABLE _result_check_file)
     if(NOT out_var) # when a directory exists but is empty the output is empty
       set(${file_exists} "YES")
     else()
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 40821e0..782e8ad 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -695,6 +695,7 @@
       -type f \( -perm -0100 -o -perm -0010 -o -perm -0001 \)
       OUTPUT_VARIABLE file_list
       OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _result_find
       )
     string(REPLACE "\n" ";" file_list "${file_list}")
   else()
@@ -991,7 +992,9 @@
     if (NOT EXISTS "${target_dir}")
       file(MAKE_DIRECTORY "${target_dir}")
     endif()
-    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${symlink_target}" "${resolved_embedded_item}")
+    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${symlink_target}"
+      "${resolved_embedded_item}"
+      RESULT_VARIABLE _result_symlink)
   endif()
 endfunction()
 
@@ -1009,7 +1012,9 @@
     message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
   else()
     #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
-    execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}")
+    execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}"
+      "${resolved_embedded_item}"
+      RESULT_VARIABLE _result_copy)
     if(UNIX AND NOT APPLE)
       file(RPATH_REMOVE FILE "${resolved_embedded_item}")
     endif()
@@ -1042,14 +1047,18 @@
     else()
       # Framework lib itself:
       #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
-      execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}")
+      execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}"
+        "${resolved_embedded_item}"
+        RESULT_VARIABLE _result_copy)
 
       # Plus Resources, if they exist:
       string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}")
       string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}")
       if(EXISTS "${resolved_resources}")
         #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_resources}' '${resolved_embedded_resources}'")
-        execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_resources}" "${resolved_embedded_resources}")
+        execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory
+          "${resolved_resources}" "${resolved_embedded_resources}"
+          RESULT_VARIABLE _result_copy_resources)
       endif()
 
       # Some frameworks e.g. Qt put Info.plist in wrong place, so when it is
@@ -1060,7 +1069,9 @@
         string(REGEX REPLACE "^(.*)/[^/]+$" "\\1/Resources/Info.plist" resolved_embedded_info_plist "${resolved_embedded_item}")
         if(EXISTS "${resolved_info_plist}")
           #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_info_plist}' '${resolved_embedded_info_plist}'")
-          execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_info_plist}" "${resolved_embedded_info_plist}")
+          execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+            "${resolved_info_plist}" "${resolved_embedded_info_plist}"
+            RESULT_VARIABLE _result_copy_info_plist)
         endif()
       endif()
 
@@ -1071,17 +1082,25 @@
       if(resolved_embedded_versions_basename STREQUAL "Versions")
         # Ensure Current symlink points to the framework version
         if(NOT EXISTS "${resolved_embedded_versions}/Current")
-          execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${resolved_embedded_version}" "${resolved_embedded_versions}/Current")
+          execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+            "${resolved_embedded_version}"
+            "${resolved_embedded_versions}/Current"
+            RESULT_VARIABLE _result_symlink_current)
         endif()
         # Restore symlinks in framework root pointing to current framework
         # binary and resources:
         string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1" resolved_embedded_root "${resolved_embedded_item}")
         string(REGEX REPLACE "^.*/([^/]+)$" "\\1" resolved_embedded_item_basename "${resolved_embedded_item}")
         if(NOT EXISTS "${resolved_embedded_root}/${resolved_embedded_item_basename}")
-          execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "Versions/Current/${resolved_embedded_item_basename}" "${resolved_embedded_root}/${resolved_embedded_item_basename}")
+          execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+            "Versions/Current/${resolved_embedded_item_basename}"
+            "${resolved_embedded_root}/${resolved_embedded_item_basename}"
+            RESULT_VARIABLE _result_symlink_item)
         endif()
         if(NOT EXISTS "${resolved_embedded_root}/Resources")
-          execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "Versions/Current/Resources" "${resolved_embedded_root}/Resources")
+          execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+            "Versions/Current/Resources" "${resolved_embedded_root}/Resources"
+            RESULT_VARIABLE _result_symlink_resources)
         endif()
       endif()
     endif()
@@ -1156,6 +1175,7 @@
   execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL}
     OUTPUT_VARIABLE install_name_tool_usage
     ERROR_VARIABLE  install_name_tool_usage
+    RESULT_VARIABLE _result_install_name_tool_usage
     )
   if(install_name_tool_usage MATCHES ".*-delete_rpath.*")
     foreach(rpath ${${ikey}_RPATHS})
@@ -1177,7 +1197,8 @@
        NOT file_contents MATCHES "^#!")
       set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}")
       if(BU_CHMOD_BUNDLE_ITEMS)
-        execute_process(COMMAND chmod u+w "${resolved_embedded_item}")
+        execute_process(COMMAND chmod u+w "${resolved_embedded_item}"
+          RESULT_VARIABLE _result_chmod)
       endif()
       execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result)
       if(NOT install_name_tool_result EQUAL 0)
@@ -1278,7 +1299,8 @@
 
 
 function(copy_and_fixup_bundle src dst libs dirs)
-  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${src}" "${dst}")
+  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${src}" "${dst}"
+    RESULT_VARIABLE _result_copy_directory)
   fixup_bundle("${dst}" "${libs}" "${dirs}")
 endfunction()
 
diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake
index 54e5153..c60aef0 100644
--- a/Modules/CMakeASM_NASMInformation.cmake
+++ b/Modules/CMakeASM_NASMInformation.cmake
@@ -8,30 +8,34 @@
 
 if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT)
   if(WIN32)
-    if(DEFINED CMAKE_C_SIZEOF_DATA_PTR AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+    if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8 OR CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
       set(CMAKE_ASM_NASM_OBJECT_FORMAT win64)
-    elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
-      set(CMAKE_ASM_NASM_OBJECT_FORMAT win64)
+    elseif(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4 OR CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4)
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT win32)
     elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
       set(CMAKE_ASM_NASM_OBJECT_FORMAT win64)
     else()
       set(CMAKE_ASM_NASM_OBJECT_FORMAT win32)
     endif()
   elseif(APPLE)
-    if(DEFINED CMAKE_C_SIZEOF_DATA_PTR AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+    if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8 OR CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
       set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
-    elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
-      set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
+    elseif(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4 OR CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4)
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT macho32)
     elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
       set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
     else()
       set(CMAKE_ASM_NASM_OBJECT_FORMAT macho)
     endif()
   else()
-    if(DEFINED CMAKE_C_SIZEOF_DATA_PTR AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+    if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8 OR CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
       set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
-    elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
-      set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
+    elseif(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4 OR CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4)
+      if(";${CMAKE_C_COMPILER_ARCHITECTURE_ID};${CMAKE_CXX_COMPILER_ARCHITECTURE_ID};" MATCHES ";x86_64;")
+        set(CMAKE_ASM_NASM_OBJECT_FORMAT elfx32)
+      else()
+        set(CMAKE_ASM_NASM_OBJECT_FORMAT elf32)
+      endif()
     elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
       set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
     else()
@@ -41,7 +45,7 @@
 endif()
 
 if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT)
-  set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
+  set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <DEFINES> <INCLUDES> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} <FLAGS> -o <OBJECT> <SOURCE>")
 endif()
 
 if(NOT CMAKE_ASM_NASM_LINK_EXECUTABLE)
diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake
index 7eec1f2..3b45f17 100644
--- a/Modules/CMakeAddFortranSubdirectory.cmake
+++ b/Modules/CMakeAddFortranSubdirectory.cmake
@@ -154,7 +154,8 @@
     set(_mingw_target "Target:.*mingw32")
   endif()
   execute_process(COMMAND "${MINGW_GFORTRAN}" -v
-    ERROR_VARIABLE out ERROR_STRIP_TRAILING_WHITESPACE)
+    ERROR_VARIABLE out ERROR_STRIP_TRAILING_WHITESPACE
+    RESULT_VARIABLE _result_mingw_gfortran_v)
   if(NOT "${out}" MATCHES "${_mingw_target}")
     string(REPLACE "\n" "\n  " out "  ${out}")
     message(FATAL_ERROR
diff --git a/Modules/CMakeDetermineCSharpCompiler.cmake b/Modules/CMakeDetermineCSharpCompiler.cmake
index 0528252..7512e69 100644
--- a/Modules/CMakeDetermineCSharpCompiler.cmake
+++ b/Modules/CMakeDetermineCSharpCompiler.cmake
@@ -22,7 +22,10 @@
   include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
   CMAKE_DETERMINE_COMPILER_ID(CSharp CSFLAGS CMakeCSharpCompilerId.cs)
 
-  execute_process(COMMAND "${CMAKE_CSharp_COMPILER}" "/help /preferreduilang:en-US" OUTPUT_VARIABLE output)
+  execute_process(COMMAND "${CMAKE_CSharp_COMPILER}"
+    "/help /preferreduilang:en-US"
+    OUTPUT_VARIABLE output
+    RESULT_VARIABLE _result_csharp_help)
   string(REPLACE "\n" ";" output "${output}")
   foreach(line ${output})
     string(TOUPPER ${line} line)
diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake
index e9285b6..d1c09fc 100644
--- a/Modules/CMakeDetermineSwiftCompiler.cmake
+++ b/Modules/CMakeDetermineSwiftCompiler.cmake
@@ -99,7 +99,8 @@
   # Execute in dry-run mode so no compilation will be actually performed.
   execute_process(COMMAND ${_CMAKE_Swift_COMPILER_CHECK_COMMAND}
     WORKING_DIRECTORY "${CMAKE_Swift_COMPILER_DRIVER_TEST_DIR}"
-    OUTPUT_VARIABLE _CMAKE_Swift_COMPILER_CHECK_OUTPUT)
+    OUTPUT_VARIABLE _CMAKE_Swift_COMPILER_CHECK_OUTPUT
+    RESULT_VARIABLE _result_CMAKE_Swift_COMPILER)
 
   # Check the first frontend execution.  It is on the first line of output.
   # The old driver treats all inputs as Swift sources while the new driver
@@ -133,7 +134,8 @@
   endif()
   execute_process(
     COMMAND ${target_info_command}
-    OUTPUT_VARIABLE swift_target_info)
+    OUTPUT_VARIABLE swift_target_info
+    RESULT_VARIABLE _result_swift_target_info)
   message(CONFIGURE_LOG "Swift target info:\n" "${swift_target_info}")
   string(JSON module_triple GET "${swift_target_info}" "target" "moduleTriple")
   set(CMAKE_Swift_MODULE_TRIPLE ${module_triple})
diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake
index c9a9fb9..4f14874 100644
--- a/Modules/CMakeDetermineVSServicePack.cmake
+++ b/Modules/CMakeDetermineVSServicePack.cmake
@@ -121,6 +121,7 @@
           COMMAND ${CMAKE_CXX_COMPILER} -?
           ERROR_VARIABLE _output
           OUTPUT_QUIET
+          RESULT_VARIABLE _result_cl_help
         )
 
       if(_output MATCHES "Compiler Version (([0-9]+)\\.([0-9]+)\\.([0-9]+)(\\.([0-9]+))?)")
diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
index 0b21e36..b1e65c9 100644
--- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
+++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
@@ -31,7 +31,8 @@
   execute_process(COMMAND ${_compilerExecutable} ${_arg1} ${_stdver} ${_stdlib} -v -E -x ${_lang} -dD dummy
                   WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
                   ERROR_VARIABLE _gccOutput
-                  OUTPUT_VARIABLE _gccStdout )
+                  OUTPUT_VARIABLE _gccStdout
+                  RESULT_VARIABLE _result_gcc)
   file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy")
 
   # First find the system include dirs:
diff --git a/Modules/CMakeFindJavaCommon.cmake b/Modules/CMakeFindJavaCommon.cmake
index 95ca9b5..f3e3493 100644
--- a/Modules/CMakeFindJavaCommon.cmake
+++ b/Modules/CMakeFindJavaCommon.cmake
@@ -22,6 +22,7 @@
         OUTPUT_VARIABLE _CMD_JAVA_HOME
         OUTPUT_STRIP_TRAILING_WHITESPACE
         ERROR_QUIET
+        RESULT_VARIABLE _result_java_home
       )
     endif()
     if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}")
diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake
index 6e2762c..62e33e0 100644
--- a/Modules/CMakeFindPackageMode.cmake
+++ b/Modules/CMakeFindPackageMode.cmake
@@ -71,7 +71,9 @@
       find_program(FILE_EXECUTABLE file)
       if(FILE_EXECUTABLE)
         get_filename_component(FILE_ABSPATH "${FILE_EXECUTABLE}" ABSOLUTE)
-        execute_process(COMMAND "${FILE_ABSPATH}" "${FILE_ABSPATH}" OUTPUT_VARIABLE fileOutput ERROR_QUIET)
+        execute_process(COMMAND "${FILE_ABSPATH}" "${FILE_ABSPATH}"
+          OUTPUT_VARIABLE fileOutput ERROR_QUIET
+          RESULT_VARIABLE _result_file)
         if("${fileOutput}" MATCHES "64-bit")
           set(CMAKE_SIZEOF_VOID_P 8)
         endif()
diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake
index f36c022..acde687 100644
--- a/Modules/CTestCoverageCollectGCOV.cmake
+++ b/Modules/CTestCoverageCollectGCOV.cmake
@@ -419,7 +419,9 @@
     "--mtime=1970-01-01 0:0:0 UTC"
     "--format=gnutar"
     --files-from=${coverage_dir}/coverage_file_list.txt
-    WORKING_DIRECTORY ${binary_dir})
+    WORKING_DIRECTORY ${binary_dir}
+    RESULT_VARIABLE _result_tar
+    )
 
   if (GCOV_DELETE)
     foreach(gcov_file ${unfiltered_gcov_files})
diff --git a/Modules/ExternalProject/shared_internal_commands.cmake b/Modules/ExternalProject/shared_internal_commands.cmake
index 64ad3e3..71d95c4 100644
--- a/Modules/ExternalProject/shared_internal_commands.cmake
+++ b/Modules/ExternalProject/shared_internal_commands.cmake
@@ -13,6 +13,7 @@
     OUTPUT_VARIABLE git_symbolic_ref
     OUTPUT_STRIP_TRAILING_WHITESPACE
     ERROR_QUIET
+    RESULT_VARIABLE _result_git_symbolic_ref
   )
 
   if(NOT git_symbolic_ref STREQUAL "")
@@ -24,6 +25,7 @@
       OUTPUT_VARIABLE git_remote_name
       OUTPUT_STRIP_TRAILING_WHITESPACE
       ERROR_QUIET
+      RESULT_VARIABLE _result_git_branch_remote
     )
   endif()
 
@@ -36,6 +38,7 @@
       OUTPUT_VARIABLE git_remote_list
       OUTPUT_STRIP_TRAILING_WHITESPACE
       ERROR_QUIET
+      RESULT_VARIABLE _result_git_remote_list
     )
     string(REPLACE "\n" ";" git_remote_list "${git_remote_list}")
     list(LENGTH git_remote_list git_remote_list_length)
@@ -70,6 +73,7 @@
     OUTPUT_STRIP_TRAILING_WHITESPACE
     COMMAND_ERROR_IS_FATAL LAST
     ENCODING UTF-8   # Needed to handle non-ascii characters in local paths
+    RESULT_VARIABLE _result_git_remote_url
   )
 
   set("${output_variable}" "${git_remote_url}" PARENT_SCOPE)
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 73e30d2..98ac302 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -1022,7 +1022,9 @@
     endif()
   elseif(CUDAToolkit_NVCC_EXECUTABLE)
     # Compute the version by invoking nvcc
-    execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT)
+    execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "--version"
+      OUTPUT_VARIABLE NVCC_OUT
+      RESULT_VARIABLE _nvcc_version_result)
     if(NVCC_OUT MATCHES [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=])
       set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
       set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake
index 9af420f..d5ca65e 100644
--- a/Modules/FindCURL.cmake
+++ b/Modules/FindCURL.cmake
@@ -257,16 +257,19 @@
       execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --version
                       OUTPUT_VARIABLE CURL_CONFIG_VERSION_STRING
                       ERROR_QUIET
-                      OUTPUT_STRIP_TRAILING_WHITESPACE)
+                      OUTPUT_STRIP_TRAILING_WHITESPACE
+                      RESULT_VARIABLE _curl_config_version_result)
       execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --feature
                       OUTPUT_VARIABLE CURL_CONFIG_FEATURES_STRING
                       ERROR_QUIET
-                      OUTPUT_STRIP_TRAILING_WHITESPACE)
+                      OUTPUT_STRIP_TRAILING_WHITESPACE
+                      RESULT_VARIABLE _curl_config_features_result)
       string(REPLACE "\n" ";" CURL_SUPPORTED_FEATURES "${CURL_CONFIG_FEATURES_STRING}")
       execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --protocols
                       OUTPUT_VARIABLE CURL_CONFIG_PROTOCOLS_STRING
                       ERROR_QUIET
-                      OUTPUT_STRIP_TRAILING_WHITESPACE)
+                      OUTPUT_STRIP_TRAILING_WHITESPACE
+                      RESULT_VARIABLE _curl_config_protocols_result)
       string(REPLACE "\n" ";" CURL_SUPPORTED_PROTOCOLS "${CURL_CONFIG_PROTOCOLS_STRING}")
     endif()
   endif()
diff --git a/Modules/FindEnvModules.cmake b/Modules/FindEnvModules.cmake
index bb19d04..40f0875 100644
--- a/Modules/FindEnvModules.cmake
+++ b/Modules/FindEnvModules.cmake
@@ -229,6 +229,7 @@
   execute_process(
     COMMAND mktemp -t module.cmake.XXXXXXXXXXXX
     OUTPUT_VARIABLE tempfile_name
+    RESULT_VARIABLE _tempfile_result
   )
   string(STRIP "${tempfile_name}" tempfile_name)
 
diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake
index eed585c..9b4605f 100644
--- a/Modules/FindFLTK.cmake
+++ b/Modules/FindFLTK.cmake
@@ -289,7 +289,9 @@
     find_program(FLTK_CONFIG_SCRIPT fltk-config PATHS ${FLTK_BIN_DIR})
     if(FLTK_CONFIG_SCRIPT)
       if(NOT FLTK_INCLUDE_DIR)
-        execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --cxxflags OUTPUT_VARIABLE FLTK_CXXFLAGS)
+        execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --cxxflags
+          OUTPUT_VARIABLE FLTK_CXXFLAGS
+          RESULT_VARIABLE _fltk_cxxflags_result)
         if(FLTK_CXXFLAGS)
           string(REGEX MATCHALL "-I[^ ]*" _fltk_temp_dirs ${FLTK_CXXFLAGS})
           string(REPLACE "-I" "" _fltk_temp_dirs "${_fltk_temp_dirs}")
@@ -313,7 +315,9 @@
   # Try to find FLTK library
   if(UNIX)
     if(FLTK_CONFIG_SCRIPT)
-      execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --libs OUTPUT_VARIABLE _FLTK_POSSIBLE_LIBS)
+      execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --libs
+        OUTPUT_VARIABLE _FLTK_POSSIBLE_LIBS
+        RESULT_VARIABLE _fltk_config_libs_result)
       if(_FLTK_POSSIBLE_LIBS)
         get_filename_component(_FLTK_POSSIBLE_LIBRARY_DIR ${_FLTK_POSSIBLE_LIBS} PATH)
       endif()
@@ -350,7 +354,8 @@
   if(UNIX)
     if(FLTK_CONFIG_SCRIPT)
       execute_process(COMMAND ${FLTK_CONFIG_SCRIPT} --use-images --ldflags
-        OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS)
+        OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS
+        RESULT_VARIABLE _fltk_images_ldflags_result)
       set(FLTK_LIBS_EXTRACT_REGEX ".*-lfltk_images (.*) -lfltk.*")
       if("${FLTK_IMAGES_LDFLAGS}" MATCHES "${FLTK_LIBS_EXTRACT_REGEX}")
         string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${CMAKE_MATCH_1}")
diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake
index 041e9d1..0d30ffb 100644
--- a/Modules/FindGSL.cmake
+++ b/Modules/FindGSL.cmake
@@ -171,7 +171,8 @@
     execute_process(
       COMMAND "${GSL_CONFIG_EXECUTABLE}" --version
       OUTPUT_VARIABLE GSL_VERSION
-      OUTPUT_STRIP_TRAILING_WHITESPACE )
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _gsl_config_version_result)
   endif()
 
   # 2. If gsl-config is not available, try looking in gsl/gsl_version.h
diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake
index 347d30d..1330580 100644
--- a/Modules/FindGettext.cmake
+++ b/Modules/FindGettext.cmake
@@ -413,7 +413,8 @@
   execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
                   OUTPUT_VARIABLE gettext_version
                   ERROR_QUIET
-                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+                  OUTPUT_STRIP_TRAILING_WHITESPACE
+                  RESULT_VARIABLE _gettext_msgmerge_version_result)
   get_filename_component(msgmerge_name ${GETTEXT_MSGMERGE_EXECUTABLE} NAME)
   get_filename_component(msgmerge_namewe ${GETTEXT_MSGMERGE_EXECUTABLE} NAME_WE)
   if(gettext_version MATCHES "^(${msgmerge_name}|${msgmerge_namewe}) \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake
index f5bf309..5a22735 100644
--- a/Modules/FindGnuplot.cmake
+++ b/Modules/FindGnuplot.cmake
@@ -87,7 +87,8 @@
     execute_process(COMMAND "${GNUPLOT_EXECUTABLE}" --version
                   OUTPUT_VARIABLE GNUPLOT_OUTPUT_VARIABLE
                   ERROR_QUIET
-                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+                  OUTPUT_STRIP_TRAILING_WHITESPACE
+                  RESULT_VARIABLE _gnuplot_version_result)
 
     string(REGEX REPLACE "^gnuplot ([0-9\\.]+)( patchlevel )?" "\\1." Gnuplot_VERSION "${GNUPLOT_OUTPUT_VARIABLE}")
     string(REGEX REPLACE "\\.$" "" Gnuplot_VERSION "${Gnuplot_VERSION}")
diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake
index a0be791..f672ba8 100644
--- a/Modules/FindIce.cmake
+++ b/Modules/FindIce.cmake
@@ -662,7 +662,8 @@
 
     execute_process(COMMAND ${Ice_SLICE2CPP_EXECUTABLE} --version
       ERROR_VARIABLE Ice_VERSION_SLICE2CPP_FULL
-      ERROR_STRIP_TRAILING_WHITESPACE)
+      ERROR_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _slice2cpp_version_result)
 
     # restore the previous LC_ALL
     set(ENV{LC_ALL} ${_Ice_SAVED_LC_ALL})
diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake
index ea9cb04..b4eeb7e 100644
--- a/Modules/FindIcotool.cmake
+++ b/Modules/FindIcotool.cmake
@@ -81,6 +81,7 @@
     OUTPUT_VARIABLE Icotool_VERSION
     ERROR_QUIET
     OUTPUT_STRIP_TRAILING_WHITESPACE
+    RESULT_VARIABLE _icotool_version_result
   )
   if("${Icotool_VERSION}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
     set(Icotool_VERSION "${CMAKE_MATCH_1}")
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index c34ebdb..d1b482c 100644
--- a/Modules/FindImageMagick.cmake
+++ b/Modules/FindImageMagick.cmake
@@ -285,6 +285,7 @@
       OUTPUT_VARIABLE version
       ERROR_QUIET
       OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _version_result
     )
 
     if(version MATCHES "^Version: ImageMagick ([-0-9.]+)")
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 5e3b365..5f7c83b 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1083,6 +1083,7 @@
     OUTPUT_VARIABLE _matlab_mex_extension
     ERROR_VARIABLE _matlab_mex_extension_error
     OUTPUT_STRIP_TRAILING_WHITESPACE
+    RESULT_VARIABLE _matlab_mex_extension_result
     ${devnull})
 
   if(_matlab_mex_extension_error)
diff --git a/Modules/FindODBC.cmake b/Modules/FindODBC.cmake
index 69c6ddb..a668072 100644
--- a/Modules/FindODBC.cmake
+++ b/Modules/FindODBC.cmake
@@ -163,9 +163,11 @@
 if (UNIX AND ODBC_CONFIG)
   # unixODBC and iODBC accept unified command line options
   execute_process(COMMAND ${ODBC_CONFIG} --cflags
-    OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE)
+    OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE
+    RESULT_VARIABLE _odbc_config_cflags_result)
   execute_process(COMMAND ${ODBC_CONFIG} --libs
-    OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE)
+    OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE
+    RESULT_VARIABLE _odbc_config_libs_result)
 
   # Collect paths of include directories from CFLAGS
   separate_arguments(_cflags NATIVE_COMMAND "${_cflags}")
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index 6ef1152..55f2de7 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -365,7 +365,8 @@
             COMMAND ${CMAKE_${LANG}_COMPILER} -print-search-dirs
             OUTPUT_VARIABLE output_lines
             COMMAND_ERROR_IS_FATAL ANY
-            ERROR_QUIET)
+            ERROR_QUIET
+            RESULT_VARIABLE _result_lcc_output)
           if("${output_lines}" MATCHES ".*\nlibraries:[ \t]+(.*:)\n.*")
             string(REPLACE ":" ";" implicit_dirs_addon "${CMAKE_MATCH_1}")
             list(PREPEND OpenMP_${LANG}_IMPLICIT_LINK_DIRS ${implicit_dirs_addon})
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 62baba1..cec56ac 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -992,7 +992,8 @@
   if(Protobuf_PROTOC_EXECUTABLE)
     # Check Protobuf compiler version to be aligned with libraries version
     execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --version
-                    OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION)
+                    OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION
+                    RESULT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION_RESULT)
 
     if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)")
       set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 272b176..f8e9705 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -483,7 +483,10 @@
   file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n  ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
 
 # with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file()
-  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
+  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+    "${_filenameTmp}" "${_filename}"
+    OUTPUT_QUIET ERROR_QUIET
+    RESULT_VARIABLE _result_copy)
 
 endfunction()
 
diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake
index f405e45..9622499 100644
--- a/Modules/FindSquish.cmake
+++ b/Modules/FindSquish.cmake
@@ -299,7 +299,8 @@
   set(SQUISH_CLIENT_EXECUTABLE_FOUND 1)
   execute_process(COMMAND "${SQUISH_CLIENT_EXECUTABLE}" --version
                   OUTPUT_VARIABLE _squishVersionOutput
-                  ERROR_QUIET )
+                  ERROR_QUIET
+                  RESULT_VARIABLE _squishVersionResult)
   if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
     set(SQUISH_VERSION_MAJOR "${CMAKE_MATCH_1}")
     set(SQUISH_VERSION_MINOR "${CMAKE_MATCH_2}")
diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake
index 81a2cbf..f57b8b2 100644
--- a/Modules/FindTclsh.cmake
+++ b/Modules/FindTclsh.cmake
@@ -139,7 +139,8 @@
                   COMMAND "${TCL_TCLSH}"
                   OUTPUT_VARIABLE Tclsh_VERSION
                   ERROR_QUIET
-                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+                  OUTPUT_STRIP_TRAILING_WHITESPACE
+                  RESULT_VARIABLE _tclsh_version_result)
   set(TCLSH_VERSION_STRING "${Tclsh_VERSION}")
 endif()
 
diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake
index 7b4cc41..4ffcf8a 100644
--- a/Modules/FindXCTest.cmake
+++ b/Modules/FindXCTest.cmake
@@ -150,7 +150,8 @@
 execute_process(
   COMMAND xcrun --find xctest
   OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
-  ERROR_VARIABLE _xcrun_err)
+  ERROR_VARIABLE _xcrun_err
+  RESULT_VARIABLE _xcrun_result)
 if(_xcrun_out)
   set(XCTest_EXECUTABLE "${_xcrun_out}" CACHE FILEPATH "XCTest executable")
   mark_as_advanced(XCTest_EXECUTABLE)
diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake
index 90cb0b7..f869cce 100644
--- a/Modules/FindwxWindows.cmake
+++ b/Modules/FindwxWindows.cmake
@@ -708,7 +708,8 @@
       # rpath:
       execute_process(COMMAND ${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE}
         ${WX_CONFIG_ARGS_LIBS}
-        OUTPUT_VARIABLE WX_CONFIG_LIBS )
+        OUTPUT_VARIABLE WX_CONFIG_LIBS
+        RESULT_VARIABLE _wx_config_libs_result)
 
       ## extract linkdirs (-L) for rpath
       ## use regular expression to match wildcard equivalent "-L*<endchar>"
diff --git a/Modules/Internal/CMakeCUDAFindToolkit.cmake b/Modules/Internal/CMakeCUDAFindToolkit.cmake
index 8fd4089..ff67ef0 100644
--- a/Modules/Internal/CMakeCUDAFindToolkit.cmake
+++ b/Modules/Internal/CMakeCUDAFindToolkit.cmake
@@ -110,7 +110,8 @@
   # each of which has a different layout, we need to extract the CUDA toolkit root from the compiler
   # itself, allowing us to support numerous different scattered toolkit layouts
   execute_process(COMMAND ${_CUDA_NVCC_EXECUTABLE} "-v" "__cmake_determine_cuda"
-    OUTPUT_VARIABLE _CUDA_NVCC_OUT ERROR_VARIABLE _CUDA_NVCC_OUT)
+    OUTPUT_VARIABLE _CUDA_NVCC_OUT ERROR_VARIABLE _CUDA_NVCC_OUT
+    RESULT_VARIABLE _result_nvcc_out)
   if(_CUDA_NVCC_OUT MATCHES "\\#\\$ TOP=([^\r\n]*)")
     get_filename_component(${lang_var_}TOOLKIT_ROOT "${CMAKE_MATCH_1}" ABSOLUTE)
   else()
@@ -161,7 +162,9 @@
   # For regular nvcc we the toolkit version is the same as the compiler version and we can parse it from the vendor test output.
   # For Clang we need to invoke nvcc to get version output.
   if(CMAKE_${lang}_COMPILER_ID STREQUAL "Clang")
-    execute_process(COMMAND ${_CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT)
+    execute_process(COMMAND ${_CUDA_NVCC_EXECUTABLE} "--version"
+      OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
+      RESULT_VARIABLE _result_nvcc_version)
   endif()
 
   if(CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES [=[V([0-9]+\.[0-9]+\.[0-9]+)]=])
diff --git a/Modules/Internal/CMakeChipStarHIP.cmake b/Modules/Internal/CMakeChipStarHIP.cmake
index 1249220..4e03b76 100644
--- a/Modules/Internal/CMakeChipStarHIP.cmake
+++ b/Modules/Internal/CMakeChipStarHIP.cmake
@@ -42,7 +42,8 @@
   set(_hip_path "$ENV{HIP_PATH}")
   if(NOT IS_DIRECTORY "${_hip_path}")
     execute_process(COMMAND hipconfig --rocmpath
-      OUTPUT_VARIABLE _hip_path OUTPUT_STRIP_TRAILING_WHITESPACE)
+      OUTPUT_VARIABLE _hip_path OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _result_hipconfig)
   endif()
   if(IS_DIRECTORY "${_hip_path}")
     file(TO_CMAKE_PATH "${_hip_path}" _hip_path)
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake
index 1ebcaaa..c4d7155 100644
--- a/Modules/Internal/CPack/CPackDeb.cmake
+++ b/Modules/Internal/CPack/CPackDeb.cmake
@@ -382,6 +382,7 @@
         OUTPUT_VARIABLE _TMP_VERSION
         ERROR_QUIET
         OUTPUT_STRIP_TRAILING_WHITESPACE
+        RESULT_VARIABLE _result_shlibdeps_version
       )
       if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
         set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
@@ -413,6 +414,7 @@
           OUTPUT_VARIABLE _TMP_HELP
           ERROR_QUIET
           OUTPUT_STRIP_TRAILING_WHITESPACE
+          RESULT_VARIABLE _result_shlibdeps_help
         )
         if(_TMP_HELP MATCHES "--ignore-missing-info")
           set(IGNORE_MISSING_INFO_FLAG "--ignore-missing-info")
@@ -621,6 +623,7 @@
       COMMAND "${DPKG_EXECUTABLE}" --print-architecture
       OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
       OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _result_dpkg_arch
     )
   endif()
 
@@ -878,6 +881,7 @@
         COMMAND "${DPKG_EXECUTABLE}" --version
         OUTPUT_VARIABLE DPKG_VERSION
         OUTPUT_STRIP_TRAILING_WHITESPACE
+        RESULT_VARIABLE _result_dpkg_version
       )
       set(_dpkg_version_re "Debian 'dpkg' package management program version ([0-9]+\.[0-9]+\.[0-9]+).*")
       if(DPKG_VERSION MATCHES "${_dpkg_version_re}")
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
index 75b3b40..8466550 100644
--- a/Modules/Internal/CPack/CPackRPM.cmake
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -67,6 +67,7 @@
       OUTPUT_VARIABLE permissions_str
       ERROR_QUIET
       OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _result_stat_permissions
     )
 
   string(REGEX REPLACE "(.)" "\\1;" permissions "${permissions_str}")
@@ -581,7 +582,9 @@
                   BASE_DIRECTORY "${SYMLINK_LOCATION_}"
                   OUTPUT_VARIABLE FINAL_PATH_
                 )
-              execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}")
+              execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
+                "${FINAL_PATH_}" "${WDIR}/${F}"
+                RESULT_VARIABLE _result_symlink_creation)
             else()
               # relocation subpaths
               cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
@@ -598,7 +601,9 @@
               "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
         else()
           # is not relocatable or points to non relocatable path - permanent symlink
-          execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}")
+          execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
+            "${SYMLINK_POINT_WD_}" "${WDIR}/${F}"
+            RESULT_VARIABLE _result_symlink_creation)
         endif()
       endif()
     elseif(IS_DIRECTORY "${WDIR}/${F}")
@@ -840,7 +845,8 @@
   execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version
                   OUTPUT_VARIABLE _TMP_VERSION
                   ERROR_QUIET
-                  OUTPUT_STRIP_TRAILING_WHITESPACE)
+                  OUTPUT_STRIP_TRAILING_WHITESPACE
+                  RESULT_VARIABLE _TMP_VERSION_RESULT)
   string(REGEX REPLACE "^.* " ""
          RPMBUILD_EXECUTABLE_VERSION
          ${_TMP_VERSION})
@@ -857,7 +863,8 @@
       execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a
                       OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
                       ERROR_QUIET
-                      OUTPUT_STRIP_TRAILING_WHITESPACE)
+                      OUTPUT_STRIP_TRAILING_WHITESPACE
+                      RESULT_VARIABLE _TMP_LSB_RELEASE_RESULT)
       string(REGEX REPLACE "\n" ", "
              LSB_RELEASE_OUTPUT
              ${_TMP_LSB_RELEASE_OUTPUT})
@@ -953,7 +960,8 @@
   if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
     execute_process(COMMAND uname "-m"
                     OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
-                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+                    OUTPUT_STRIP_TRAILING_WHITESPACE
+                    RESULT_VARIABLE _TMP_UNAME_RESULT)
   else()
     if(CPACK_RPM_PACKAGE_DEBUG)
       message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
@@ -1113,7 +1121,8 @@
     execute_process(
       COMMAND "${RPM_EXECUTABLE}" --querytags
       OUTPUT_VARIABLE RPMBUILD_TAG_LIST
-      OUTPUT_STRIP_TRAILING_WHITESPACE)
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      RESULT_VARIABLE _result_rpm)
   endif()
   string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}")
 
@@ -1668,6 +1677,7 @@
     execute_process(
         COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${CPACK_RPM_DIRECTORY}/SOURCES/${archive_name_}.tar.gz" "${CPACK_PACKAGE_FILE_NAME}"
         WORKING_DIRECTORY ${CPACK_RPM_DIRECTORY}
+        RESULT_VARIABLE _result_tar
       )
     set(TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz")
 
diff --git a/Modules/SquishTestScript.cmake b/Modules/SquishTestScript.cmake
index 9575084..d74b03e 100644
--- a/Modules/SquishTestScript.cmake
+++ b/Modules/SquishTestScript.cmake
@@ -45,7 +45,7 @@
 
 if(squish_pre_command)
   message(STATUS "Executing pre command: ${squish_pre_command}")
-  execute_process(COMMAND "${squish_pre_command}")
+  execute_process(COMMAND "${squish_pre_command}" RESULT_VARIABLE _result_pre_command)
 endif()
 
 # run the test
@@ -71,7 +71,7 @@
 
 if(squish_post_command)
   message(STATUS "Executing post command: ${squish_post_command}")
-  execute_process(COMMAND "${squish_post_command}")
+  execute_process(COMMAND "${squish_post_command}" RESULT_VARIABLE _result_post_command)
 endif()
 
 # check for an error with running the test
diff --git a/Modules/UseJava/Symlinks.cmake b/Modules/UseJava/Symlinks.cmake
index 3142dca..6281067 100644
--- a/Modules/UseJava/Symlinks.cmake
+++ b/Modules/UseJava/Symlinks.cmake
@@ -13,6 +13,7 @@
         execute_process(
             COMMAND ${LN_EXECUTABLE} -sf "${_JAVA_TARGET_OUTPUT_NAME}" "${_JAVA_TARGET_OUTPUT_LINK}"
             WORKING_DIRECTORY ${_JAVA_TARGET_DIR}
+            RESULT_VARIABLE _result_symlink_creation
         )
     else ()
         message(SEND_ERROR "FATAL: Can't find _JAVA_TARGET_OUTPUT_NAME")
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 4558c81..956232c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 4)
 set(CMake_VERSION_MINOR 3)
-set(CMake_VERSION_PATCH 20260507)
+set(CMake_VERSION_PATCH 20260508)
 #set(CMake_VERSION_RC 0)
 set(CMake_VERSION_IS_DIRTY 0)
 
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 7f41fcf..62e3d80 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1084,15 +1084,35 @@
   }
 }
 
+namespace {
+std::string const gcc_s = "gcc_s";
+std::string const gcc_s_asneeded = "gcc_s_asneeded";
+}
+
 void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
 {
+  auto const impliedByLinkerLanguage = [this](std::string const& lib) -> bool {
+    if (cm::contains(this->ImplicitLinkLibs, lib)) {
+      return true;
+    }
+    // As of GCC 16, `gcc` implies `gcc_s_asneeded` but `g++` implies `gcc_s`.
+    // Accept them interchangeably when linking mixed C and C++ binaries.
+    if ((lib == gcc_s_asneeded &&
+         cm::contains(this->ImplicitLinkLibs, gcc_s)) ||
+        (lib == gcc_s &&
+         cm::contains(this->ImplicitLinkLibs, gcc_s_asneeded))) {
+      return true;
+    }
+    return false;
+  };
+
   // Add libraries for this language that are not implied by the
   // linker language.
   std::string libVar = cmStrCat("CMAKE_", lang, "_IMPLICIT_LINK_LIBRARIES");
   if (cmValue libs = this->Makefile->GetDefinition(libVar)) {
     cmList libsList{ *libs };
-    for (auto const& i : libsList) {
-      if (!cm::contains(this->ImplicitLinkLibs, i)) {
+    for (std::string const& i : libsList) {
+      if (!impliedByLinkerLanguage(i)) {
         this->AddItem({ i });
       }
     }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 11b5446..6656043 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4136,6 +4136,34 @@
           id == cmPolicies::CMP0126 || id == cmPolicies::CMP0128 ||
           id == cmPolicies::CMP0136 || id == cmPolicies::CMP0141 ||
           id == cmPolicies::CMP0155))) {
+    std::unique_ptr<PolicyPushPop> ps;
+    std::unique_ptr<DiagnosticPushPop> ds;
+
+    cmPolicies::PolicyStatus const cmp0218 =
+      this->GetPolicyStatus(cmPolicies::CMP0218);
+    if (cmp0218 != cmPolicies::NEW) {
+      if (cmp0218 != cmPolicies::OLD) {
+        // Suppress warnings about using old variables.
+        ps = cm::make_unique<PolicyPushPop>(this);
+        this->SetPolicy(cmPolicies::CMP0218, cmPolicies::OLD);
+      }
+
+      ds = cm::make_unique<DiagnosticPushPop>(this);
+
+      // Use old variables to determine diagnostic action.
+      cmValue const warn = this->GetDefinition("CMAKE_WARN_DEPRECATED");
+      if (warn.IsSet() && !warn.IsOn()) {
+        this->SetDiagnostic(cmDiagnostics::CMD_DEPRECATED,
+                            cmDiagnostics::Ignore);
+      } else if (this->IsOn("CMAKE_ERROR_DEPRECATED")) {
+        this->SetDiagnostic(cmDiagnostics::CMD_DEPRECATED,
+                            cmDiagnostics::SendError);
+      } else {
+        this->SetDiagnostic(cmDiagnostics::CMD_DEPRECATED,
+                            cmDiagnostics::Warn);
+      }
+    }
+
     this->IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
                           cmPolicies::GetPolicyDeprecatedWarning(id));
   }
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 8ce1a7c..67b5af5 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -3,9 +3,9 @@
 #include "cmMessageCommand.h"
 
 #include <cassert>
-#include <memory>
 #include <utility>
 
+#include <cm/memory>
 #include <cm/string_view>
 #include <cmext/string_view>
 
@@ -16,9 +16,11 @@
 #include "cmMakefile.h"
 #include "cmMessageType.h"
 #include "cmMessenger.h"
+#include "cmPolicies.h"
 #include "cmRange.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
+#include "cmValue.h"
 #include "cmake.h"
 
 #ifdef CMake_ENABLE_DEBUGGER
@@ -96,6 +98,7 @@
 
   auto i = args.cbegin();
 
+  std::unique_ptr<cmMakefile::DiagnosticPushPop> ds;
   auto category = cmDiagnostics::CMD_NONE;
   auto type = MessageType::MESSAGE;
   auto fatal = false;
@@ -116,7 +119,7 @@
     ++i;
   } else if (*i == "AUTHOR_WARNING") {
     category = cmDiagnostics::CMD_AUTHOR;
-    switch (mf.GetDiagnosticAction(cmDiagnostics::CMD_AUTHOR)) {
+    switch (mf.GetDiagnosticAction(category)) {
       case cmDiagnostics::Ignore:
         return true;
       case cmDiagnostics::FatalError:
@@ -166,7 +169,34 @@
     ++i;
   } else if (*i == "DEPRECATION") {
     category = cmDiagnostics::CMD_DEPRECATED;
-    switch (mf.GetDiagnosticAction(cmDiagnostics::CMD_DEPRECATED)) {
+
+    cmPolicies::PolicyStatus const cmp0218 =
+      mf.GetPolicyStatus(cmPolicies::CMP0218);
+    if (cmp0218 != cmPolicies::NEW) {
+      std::unique_ptr<cmMakefile::PolicyPushPop> ps;
+
+      if (cmp0218 != cmPolicies::OLD) {
+        // Suppress warnings about using old variables.
+        ps = cm::make_unique<cmMakefile::PolicyPushPop>(&mf);
+        mf.SetPolicy(cmPolicies::CMP0218, cmPolicies::OLD);
+      }
+
+      ds = cm::make_unique<cmMakefile::DiagnosticPushPop>(&mf);
+
+      // Use old variables to determine diagnostic action.
+      if (mf.IsOn("CMAKE_ERROR_DEPRECATED")) {
+        mf.SetDiagnostic(category, cmDiagnostics::FatalError);
+      } else {
+        cmValue const warn = mf.GetDefinition("CMAKE_WARN_DEPRECATED");
+        if (warn.IsSet() && !warn.IsOn()) {
+          mf.SetDiagnostic(category, cmDiagnostics::Ignore);
+        } else {
+          mf.SetDiagnostic(category, cmDiagnostics::Warn);
+        }
+      }
+    }
+
+    switch (mf.GetDiagnosticAction(category)) {
       case cmDiagnostics::Ignore:
         return true;
       case cmDiagnostics::FatalError:
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 1ef7f10..a7aab42 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -650,7 +650,11 @@
          0, WARN)                                                             \
   SELECT(POLICY, CMP0217,                                                     \
          "The MACROS directory property does not exist anymore.", 4, 4, 0,    \
-         WARN)
+         WARN)                                                                \
+  SELECT(POLICY, CMP0218,                                                     \
+         "The CMAKE_WARN_DEPRECATED and CMAKE_ERROR_DEPRECATED variables "    \
+         "are ignored.",                                                      \
+         4, 4, 0, WARN)
 
 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
 #define CM_FOR_EACH_POLICY_ID(POLICY)                                         \
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 5ad00fe..b46bfa3 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -7,16 +7,16 @@
 #include <utility>
 #include <vector>
 
-std::string const& cmVariableWatch::GetAccessAsString(int access_type)
+std::string const& cmVariableWatch::GetAccessAsString(AccessType accessType)
 {
   static std::array<std::string, 6> const cmVariableWatchAccessStrings = {
     { "READ_ACCESS", "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
       "MODIFIED_ACCESS", "REMOVED_ACCESS", "NO_ACCESS" }
   };
-  if (access_type < 0 || access_type >= cmVariableWatch::NO_ACCESS) {
-    access_type = cmVariableWatch::NO_ACCESS;
+  if (accessType >= cmVariableWatch::NO_ACCESS) {
+    accessType = cmVariableWatch::NO_ACCESS;
   }
-  return cmVariableWatchAccessStrings[access_type];
+  return cmVariableWatchAccessStrings[accessType];
 }
 
 cmVariableWatch::cmVariableWatch() = default;
@@ -63,7 +63,8 @@
 }
 
 bool cmVariableWatch::VariableAccessed(std::string const& variable,
-                                       int access_type, char const* newValue,
+                                       AccessType accessType,
+                                       char const* newValue,
                                        cmMakefile const* mf) const
 {
   auto mit = this->WatchMap.find(variable);
@@ -77,7 +78,7 @@
       // lockable, and so this ensures we don't attempt to call into freed
       // memory
       if (auto it = weak_it.lock()) {
-        it->Method(variable, access_type, it->ClientData, newValue, mf);
+        it->Method(variable, accessType, it->ClientData, newValue, mf);
       }
     }
     return true;
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index ffd7192..0d8fff5 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -19,8 +19,21 @@
 class cmVariableWatch
 {
 public:
-  using WatchMethod = void (*)(std::string const&, int, void*, char const*,
-                               cmMakefile const*);
+  /**
+   * Different access types.
+   */
+  enum AccessType : unsigned
+  {
+    VARIABLE_READ_ACCESS,
+    UNKNOWN_VARIABLE_READ_ACCESS,
+    UNKNOWN_VARIABLE_DEFINED_ACCESS,
+    VARIABLE_MODIFIED_ACCESS,
+    VARIABLE_REMOVED_ACCESS,
+    NO_ACCESS
+  };
+
+  using WatchMethod = void (*)(std::string const&, AccessType, void*,
+                               char const*, cmMakefile const*);
   using DeleteData = void (*)(void*);
 
   cmVariableWatch();
@@ -37,26 +50,13 @@
   /**
    * This method is called when variable is accessed
    */
-  bool VariableAccessed(std::string const& variable, int access_type,
+  bool VariableAccessed(std::string const& variable, AccessType accessType,
                         char const* newValue, cmMakefile const* mf) const;
 
   /**
-   * Different access types.
-   */
-  enum
-  {
-    VARIABLE_READ_ACCESS,
-    UNKNOWN_VARIABLE_READ_ACCESS,
-    UNKNOWN_VARIABLE_DEFINED_ACCESS,
-    VARIABLE_MODIFIED_ACCESS,
-    VARIABLE_REMOVED_ACCESS,
-    NO_ACCESS
-  };
-
-  /**
    * Return the access as string
    */
-  static std::string const& GetAccessAsString(int access_type);
+  static std::string const& GetAccessAsString(AccessType accessType);
 
 protected:
   struct Pair
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index f5d47c6..930d5d6 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -25,20 +25,19 @@
   std::string Command;
 };
 
-void cmVariableWatchCommandVariableAccessed(std::string const& variable,
-                                            int access_type, void* client_data,
-                                            char const* newValue,
-                                            cmMakefile const* mf)
+void cmVariableWatchCommandVariableAccessed(
+  std::string const& variable, cmVariableWatch::AccessType accessType,
+  void* clientData, char const* newValue, cmMakefile const* mf)
 {
   cmVariableWatchCallbackData* data =
-    static_cast<cmVariableWatchCallbackData*>(client_data);
+    static_cast<cmVariableWatchCallbackData*>(clientData);
 
   if (data->InCallback) {
     return;
   }
   data->InCallback = true;
 
-  auto accessString = cmVariableWatch::GetAccessAsString(access_type);
+  auto accessString = cmVariableWatch::GetAccessAsString(accessType);
 
   /// Ultra bad!!
   cmMakefile* makefile = const_cast<cmMakefile*>(mf);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 2918cd1..ae17b90 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -40,14 +40,6 @@
 #include "cmCMakePresetsGraph.h"
 #include "cmCommandLineArgument.h"
 #include "cmCommands.h"
-#ifdef CMake_ENABLE_DEBUGGER
-#  include "cmDebuggerAdapter.h"
-#  ifdef _WIN32
-#    include "cmDebuggerWindowsPipeConnection.h"
-#  else //!_WIN32
-#    include "cmDebuggerPosixPipeConnection.h"
-#  endif //_WIN32
-#endif
 #include "cmDocumentation.h"
 #include "cmDocumentationEntry.h"
 #include "cmDuration.h"
@@ -57,18 +49,13 @@
 #include "cmGlobCacheEntry.h" // IWYU pragma: keep
 #include "cmGlobalGenerator.h"
 #include "cmGlobalGeneratorFactory.h"
+#include "cmJSONState.h"
 #include "cmLinkLineComputer.h"
+#include "cmList.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#if !defined(CMAKE_BOOTSTRAP)
-#  include "cmMakefileProfilingData.h"
-#endif
-#include "cmJSONState.h"
-#include "cmList.h"
 #include "cmMessenger.h"
-#ifndef CMAKE_BOOTSTRAP
-#  include "cmSarifLog.h"
-#endif
+#include "cmPolicies.h"
 #include "cmState.h"
 #include "cmStateDirectory.h"
 #include "cmStringAlgorithms.h"
@@ -80,6 +67,15 @@
 #include "cmVersionConfig.h"
 #include "cmWorkingDirectory.h"
 
+#ifdef CMake_ENABLE_DEBUGGER
+#  include "cmDebuggerAdapter.h"
+#  ifdef _WIN32
+#    include "cmDebuggerWindowsPipeConnection.h"
+#  else //!_WIN32
+#    include "cmDebuggerPosixPipeConnection.h"
+#  endif //_WIN32
+#endif
+
 #if !defined(CMAKE_BOOTSTRAP)
 #  include <unordered_map>
 
@@ -92,6 +88,8 @@
 #  include "cmGraphVizWriter.h"
 #  include "cmInstrumentation.h"
 #  include "cmInstrumentationQuery.h"
+#  include "cmMakefileProfilingData.h"
+#  include "cmSarifLog.h"
 #  include "cmVariableWatch.h"
 #endif
 
@@ -169,13 +167,25 @@
   cmCommandLineArgument<bool(std::string const& value, cmake* state)>;
 
 #ifndef CMAKE_BOOTSTRAP
-void cmWarnUnusedCliWarning(std::string const& variable, int /*unused*/,
-                            void* ctx, char const* /*unused*/,
+void cmWarnUnusedCliWarning(std::string const& variable,
+                            cmVariableWatch::AccessType /*unused*/, void* ctx,
+                            char const* /*unused*/,
                             cmMakefile const* /*unused*/)
 {
   cmake* cm = reinterpret_cast<cmake*>(ctx);
   cm->MarkCliAsUsed(variable);
 }
+
+void cmDeprecatedWatch(std::string const& /*unused*/,
+                       cmVariableWatch::AccessType /*unused*/,
+                       void* /*unused*/, char const* /*unused*/,
+                       cmMakefile const* mf)
+{
+  if (mf->GetPolicyStatus(cmPolicies::CMP0218) == cmPolicies::WARN) {
+    mf->IssueDiagnostic(cmDiagnostics::CMD_AUTHOR,
+                        cmPolicies::GetPolicyWarning(cmPolicies::CMP0218));
+  }
+}
 #endif
 
 void warnDeprecated(cm::string_view oldOption, cm::string_view newOption)
@@ -832,6 +842,15 @@
     }
   }
 
+  // See also CMP0218.
+  if (var == "CMAKE_WARN_DEPRECATED") {
+    std::cerr << "The CMAKE_WARN_DEPRECATED variable is deprecated.  "
+                 "Use -W[no-]deprecated instead.\n"_s;
+  } else if (var == "CMAKE_ERROR_DEPRECATED") {
+    std::cerr << "The CMAKE_ERROR_DEPRECATED variable is deprecated.  "
+                 "Use -W[no-]error=deprecated instead.\n"_s;
+  }
+
   this->AddCacheEntry(
     var, value, "No help, variable specified on the command line.", type);
 
@@ -2441,8 +2460,6 @@
   cmValue cachedWarnDeprecated =
     this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
   if (cachedWarnDeprecated) {
-    std::cerr << "The CMAKE_WARN_DEPRECATED variable is deprecated.  "
-                 "Use CMAKE_DIAGNOSTIC_INIT instead.\n"_s;
     if (cachedWarnDeprecated.IsOn()) {
       deprecated = cmDiagnostics::Warn;
     } else {
@@ -2453,8 +2470,6 @@
   cmValue cachedErrorDeprecated =
     this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
   if (cachedErrorDeprecated) {
-    std::cerr << "The CMAKE_ERROR_DEPRECATED variable is deprecated.  "
-                 "Use CMAKE_DIAGNOSTIC_INIT instead.\n"_s;
     if (cachedErrorDeprecated.IsOn()) {
       deprecated = cmDiagnostics::SendError;
     }
@@ -2478,22 +2493,16 @@
                cmDiagnostics::GetActionString(action)));
 
     if (category == cmDiagnostics::CMD_DEPRECATED) {
-      // Set deprecated CMAKE_{WARN,ERROR}_DEPRECATED, but only in the cache,
-      // and only if they were already set in the cache.
-      if (cachedWarnDeprecated) {
-        std::string const value =
-          (action >= cmDiagnostics::Warn ? "ON" : "OFF");
-        this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value,
-                            "Deprecated.  Use CMAKE_DIAGNOSTIC_INIT instead.",
-                            cmStateEnums::INTERNAL);
-      }
-      if (cachedErrorDeprecated) {
-        std::string const value =
-          (action >= cmDiagnostics::SendError ? "ON" : "OFF");
-        this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value,
-                            "Deprecated.  Use CMAKE_DIAGNOSTIC_INIT instead.",
-                            cmStateEnums::INTERNAL);
-      }
+      std::string const warnValue =
+        (action >= cmDiagnostics::Warn ? "ON" : "OFF");
+      this->AddCacheEntry("CMAKE_WARN_DEPRECATED", warnValue,
+                          "Deprecated.  Use -W[no-]deprecated instead.",
+                          cmStateEnums::INTERNAL);
+      std::string const errorValue =
+        (action >= cmDiagnostics::SendError ? "ON" : "OFF");
+      this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", errorValue,
+                          "Deprecated.  Use -W[no-]error=deprecated instead.",
+                          cmStateEnums::INTERNAL);
     }
   }
 
@@ -3059,6 +3068,9 @@
   if (!sarifLogFileWriter.ConfigureForCMakeRun(*this)) {
     return -1;
   }
+
+  this->VariableWatch->AddWatch("CMAKE_WARN_DEPRECATED", cmDeprecatedWatch);
+  this->VariableWatch->AddWatch("CMAKE_ERROR_DEPRECATED", cmDeprecatedWatch);
 #endif
 
   // Log the trace format version to the desired output
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 210363e..0520a5f 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1218,7 +1218,8 @@
         execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version
           OUTPUT_VARIABLE _TMP_VERSION
           ERROR_QUIET
-          OUTPUT_STRIP_TRAILING_WHITESPACE)
+          OUTPUT_STRIP_TRAILING_WHITESPACE
+          RESULT_VARIABLE _result_dpkg_version)
         if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
           set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
         else()
@@ -1963,6 +1964,7 @@
         COMMAND sw_vers -productVersion
         OUTPUT_VARIABLE OSX_VERSION
         OUTPUT_STRIP_TRAILING_WHITESPACE
+        RESULT_VARIABLE _sw_vers_result
         )
       if(OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)")
         set(CMake_TEST_XCTest_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}")
diff --git a/Tests/RunCMake/CMP0218/CMP0218-NEW.cmake b/Tests/RunCMake/CMP0218/CMP0218-NEW.cmake
new file mode 100644
index 0000000..035be35
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMP0218-NEW.cmake
@@ -0,0 +1,72 @@
+cmake_policy(SET CMP0218 NEW)
+
+function(expect NAME ACTUAL EXPECTED)
+  if(NOT "${ACTUAL}" STREQUAL "${EXPECTED}")
+    message(SEND_ERROR "${NAME} is '${ACTUAL}'; should be '${EXPECTED}'")
+  endif()
+endfunction()
+
+if(DEFINED CMAKE_WARN_DEPRECATED)
+  message(SEND_ERROR "CMAKE_WARN_DEPRECATED should not be defined")
+endif()
+
+if(DEFINED CMAKE_ERROR_DEPRECATED)
+  message(SEND_ERROR "CMAKE_ERROR_DEPRECATED should not be defined")
+endif()
+
+cmake_diagnostic(GET CMD_DEPRECATED action)
+if(NOT "${action}" STREQUAL "WARN")
+  message(SEND_ERROR "CMD_DEPRECATED is ${action}; should be WARN")
+endif()
+
+# -----------------------------------------------------------------------------
+# Setting CMAKE_WARN_DEPRECATED should have no effect on CMD_DEPRECATED
+block()
+  set(CMAKE_WARN_DEPRECATED OFF)
+
+  cmake_diagnostic(GET CMD_DEPRECATED action)
+  if(NOT "${action}" STREQUAL "WARN")
+    message(SEND_ERROR "CMD_DEPRECATED is ${action}; should be WARN")
+  endif()
+endblock()
+
+# -----------------------------------------------------------------------------
+# Setting CMAKE_ERROR_DEPRECATED should have no effect on CMD_DEPRECATED
+block()
+  set(CMAKE_ERROR_DEPRECATED ON)
+
+  cmake_diagnostic(GET CMD_DEPRECATED action)
+  if(NOT "${action}" STREQUAL "WARN")
+    message(SEND_ERROR "CMD_DEPRECATED is ${action}; should be WARN")
+  endif()
+endblock()
+
+# -----------------------------------------------------------------------------
+# Changing CMD_DEPRECATED should have no effect on variables
+block()
+  cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
+
+  if(DEFINED CMAKE_WARN_DEPRECATED)
+    message(SEND_ERROR "CMAKE_WARN_DEPRECATED should not be defined")
+  endif()
+
+  if(DEFINED CMAKE_ERROR_DEPRECATED)
+    message(SEND_ERROR "CMAKE_ERROR_DEPRECATED should not be defined")
+  endif()
+
+  expect(CMAKE_WARN_DEPRECATED "${CMAKE_WARN_DEPRECATED}" "")
+  expect(CMAKE_ERROR_DEPRECATED "${CMAKE_ERROR_DEPRECATED}" "")
+
+  cmake_diagnostic(SET CMD_DEPRECATED SEND_ERROR)
+
+  if(DEFINED CMAKE_WARN_DEPRECATED)
+    message(SEND_ERROR "CMAKE_WARN_DEPRECATED should not be defined")
+  endif()
+
+  if(DEFINED CMAKE_ERROR_DEPRECATED)
+    message(SEND_ERROR "CMAKE_ERROR_DEPRECATED should not be defined")
+  endif()
+
+  expect(CMAKE_WARN_DEPRECATED "${CMAKE_WARN_DEPRECATED}" "")
+  expect(CMAKE_ERROR_DEPRECATED "${CMAKE_ERROR_DEPRECATED}" "")
+endblock()
diff --git a/Tests/RunCMake/CMP0218/CMP0218-OLD-result.txt b/Tests/RunCMake/CMP0218/CMP0218-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMP0218-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMP0218/CMP0218-OLD-stderr.txt b/Tests/RunCMake/CMP0218/CMP0218-OLD-stderr.txt
new file mode 100644
index 0000000..2e27a1c
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMP0218-OLD-stderr.txt
@@ -0,0 +1,14 @@
+CMake Warning \(deprecated\) at [^
+]+/Tests/RunCMake/CMP0218/CMP0218-OLD\.cmake:[0-9]+ \(cmake_policy\):
+  The OLD behavior for policy CMP0153 will be removed from a future version
+  of CMake\.
+
+  The cmake-policies\(7\) manual explains that the OLD behaviors of all
+  policies are deprecated and that a policy should be set to OLD only under
+  specific short-term circumstances\.  Projects should be ported to the NEW
+  behavior and not rely on setting a policy to OLD\.
+
+
+CMake Error \(deprecated\) at [^
+]+/Tests/RunCMake/CMP0218/CMP0218-OLD\.cmake:[0-9]+ \(message\):
+  Test
diff --git a/Tests/RunCMake/CMP0218/CMP0218-OLD.cmake b/Tests/RunCMake/CMP0218/CMP0218-OLD.cmake
new file mode 100644
index 0000000..83043f3
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMP0218-OLD.cmake
@@ -0,0 +1,15 @@
+cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
+
+# Note: We're using the deprecation warning from cmMakefile::SetPolicy as a
+# test, which requires use of policies within the deprecation window (as of
+# CMake 4.4, CMP0066...CMP0155). These will likely need to be rotated to newer
+# policies when that window changes.
+
+cmake_policy(SET CMP0218 NEW)
+cmake_policy(SET CMP0152 OLD) # should be silent
+
+cmake_policy(SET CMP0218 OLD)
+cmake_policy(SET CMP0153 OLD) # should NOT be silent
+
+set(CMAKE_ERROR_DEPRECATED ON)
+message(DEPRECATION "Test") # should be error
diff --git a/Tests/RunCMake/CMP0218/CMP0218-WARN-stderr.txt b/Tests/RunCMake/CMP0218/CMP0218-WARN-stderr.txt
new file mode 100644
index 0000000..183c126
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMP0218-WARN-stderr.txt
@@ -0,0 +1,31 @@
+CMake Warning \(author\) at [^
+]+/Tests/RunCMake/CMP0218/CMP0218-WARN\.cmake:[0-9]+ \(set\):
+  Policy CMP0218 is not set: The CMAKE_WARN_DEPRECATED and
+  CMAKE_ERROR_DEPRECATED variables are ignored\.  Run "cmake --help-policy
+  CMP0218" for policy details\.  Use the cmake_policy command to set the
+  policy and suppress this warning\.
+This warning is for project developers\.  Use -Wno-author to suppress it\.
+
+CMake Warning \(author\) at [^
+]+/Tests/RunCMake/CMP0218/CMP0218-WARN\.cmake:[0-9]+ \(set\):
+  Policy CMP0218 is not set: The CMAKE_WARN_DEPRECATED and
+  CMAKE_ERROR_DEPRECATED variables are ignored\.  Run "cmake --help-policy
+  CMP0218" for policy details\.  Use the cmake_policy command to set the
+  policy and suppress this warning\.
+This warning is for project developers\.  Use -Wno-author to suppress it\.
+
+CMake Warning \(author\) at [^
+]+/Tests/RunCMake/CMP0218/CMP0218-WARN\.cmake:[0-9]+ \(set\):
+  Policy CMP0218 is not set: The CMAKE_WARN_DEPRECATED and
+  CMAKE_ERROR_DEPRECATED variables are ignored\.  Run "cmake --help-policy
+  CMP0218" for policy details\.  Use the cmake_policy command to set the
+  policy and suppress this warning\.
+This warning is for project developers\.  Use -Wno-author to suppress it\.
+
+CMake Warning \(author\) at [^
+]+/Tests/RunCMake/CMP0218/CMP0218-WARN\.cmake:[0-9]+ \(set\):
+  Policy CMP0218 is not set: The CMAKE_WARN_DEPRECATED and
+  CMAKE_ERROR_DEPRECATED variables are ignored\.  Run "cmake --help-policy
+  CMP0218" for policy details\.  Use the cmake_policy command to set the
+  policy and suppress this warning\.
+This warning is for project developers\.  Use -Wno-author to suppress it\.
diff --git a/Tests/RunCMake/CMP0218/CMP0218-WARN.cmake b/Tests/RunCMake/CMP0218/CMP0218-WARN.cmake
new file mode 100644
index 0000000..5e57da3
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMP0218-WARN.cmake
@@ -0,0 +1,8 @@
+# Test warning when setting deprecated variables.
+set(CMAKE_WARN_DEPRECATED OFF)
+message(DEPRECATION "Test")
+set(CMAKE_ERROR_DEPRECATED ON)
+
+# Test warning when reading deprecated variables.
+set(warn "${CMAKE_WARN_DEPRECATED}")
+set(error "${CMAKE_ERROR_DEPRECATED}")
diff --git a/Tests/RunCMake/CMP0218/CMakeLists.txt b/Tests/RunCMake/CMP0218/CMakeLists.txt
new file mode 100644
index 0000000..ad13db5
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 4.3) # Must be < 4.4 to test WARN
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0218/ExpectError-stderr.txt b/Tests/RunCMake/CMP0218/ExpectError-stderr.txt
new file mode 100644
index 0000000..0c122de
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/ExpectError-stderr.txt
@@ -0,0 +1 @@
+^The CMAKE_ERROR_DEPRECATED variable is deprecated\.  Use -W\[no-\]error=deprecated instead\.$
diff --git a/Tests/RunCMake/CMP0218/ExpectError.cmake b/Tests/RunCMake/CMP0218/ExpectError.cmake
new file mode 100644
index 0000000..a867217
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/ExpectError.cmake
@@ -0,0 +1,4 @@
+cmake_diagnostic(GET CMD_DEPRECATED action)
+if(NOT "${action}" STREQUAL "SEND_ERROR")
+  message(SEND_ERROR "CMD_DEPRECATED is ${action}; should be SEND_ERROR")
+endif()
diff --git a/Tests/RunCMake/CMP0218/ExpectIgnore-stderr.txt b/Tests/RunCMake/CMP0218/ExpectIgnore-stderr.txt
new file mode 100644
index 0000000..9eaed90
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/ExpectIgnore-stderr.txt
@@ -0,0 +1 @@
+^The CMAKE_WARN_DEPRECATED variable is deprecated\.  Use -W\[no-\]deprecated instead\.$
diff --git a/Tests/RunCMake/CMP0218/ExpectIgnore.cmake b/Tests/RunCMake/CMP0218/ExpectIgnore.cmake
new file mode 100644
index 0000000..c84b0f9
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/ExpectIgnore.cmake
@@ -0,0 +1,4 @@
+cmake_diagnostic(GET CMD_DEPRECATED action)
+if(NOT "${action}" STREQUAL "IGNORE")
+  message(SEND_ERROR "CMD_DEPRECATED is ${action}; should be IGNORE")
+endif()
diff --git a/Tests/RunCMake/CMP0218/RunCMakeTest.cmake b/Tests/RunCMake/CMP0218/RunCMakeTest.cmake
new file mode 100644
index 0000000..5953075
--- /dev/null
+++ b/Tests/RunCMake/CMP0218/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake_script(CMP0218-WARN)
+run_cmake_script(CMP0218-OLD)
+run_cmake_script(CMP0218-NEW)
+
+run_cmake_with_options(ExpectIgnore -DCMAKE_WARN_DEPRECATED=OFF)
+run_cmake_with_options(ExpectError -DCMAKE_ERROR_DEPRECATED=ON)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 8bf0af3..0923812 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -190,6 +190,8 @@
   add_RunCMake_test(CMP0194 -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION})
 endif()
 
+add_RunCMake_test(CMP0218)
+
 # The test for Policy 65 requires the use of the
 # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode
 # generators ignore.  The policy will have no effect on those generators.
@@ -1355,7 +1357,9 @@
 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k" AND NOT DEFINED CMake_TEST_E2K_BROKEN_LIBC)
   # Exclude tests that fail due to a broken libc version on Elbrus.
   find_program(DPKG_QUERY "dpkg-query" )
-  execute_process(COMMAND "${DPKG_QUERY}" "-f" "\${Version}" "-W" "glibc" OUTPUT_VARIABLE LIBC_VERSION)
+  execute_process(COMMAND "${DPKG_QUERY}" "-f" "\${Version}" "-W" "glibc"
+    OUTPUT_VARIABLE LIBC_VERSION
+    RESULT_VARIABLE _result_libc)
   if(LIBC_VERSION MATCHES "2.29-25.*")
     list(REMOVE_ITEM cpack_tests
       DEB.DEFAULT_PERMISSIONS
diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
index 3820dcf..6158c5d 100644
--- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake
+++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
@@ -1,4 +1,5 @@
 # Test add_compiler_export_flags without deprecation warning.
+cmake_policy(SET CMP0218 NEW)
 cmake_diagnostic(SET CMD_DEPRECATED IGNORE)
 
 project(GenerateExportHeader)
diff --git a/Tests/RunCMake/message/CMakeLists.txt b/Tests/RunCMake/message/CMakeLists.txt
index bf2ef15..8ad75a1 100644
--- a/Tests/RunCMake/message/CMakeLists.txt
+++ b/Tests/RunCMake/message/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 3.10)
+cmake_minimum_required(VERSION 4.0...4.4)
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake)
diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in
index 7cceaf2..67450e6 100644
--- a/Utilities/Sphinx/conf.py.in
+++ b/Utilities/Sphinx/conf.py.in
@@ -100,6 +100,7 @@
     r'about:',
     r'https://gitlab\.kitware\.com/cmake/community/-/wikis/doc/cpack',
     r'https://web\.archive\.org/',
+    r'https://en\.cppreference\.com/',
     r'https://www\.freedesktop\.org/',
     r'https://www\.gnu\.org/',
     r'https://www\.intel\.com/',
diff --git a/Utilities/cmlibarchive/libarchive/archive_digest_private.h b/Utilities/cmlibarchive/libarchive/archive_digest_private.h
index deb134e..5518799 100644
--- a/Utilities/cmlibarchive/libarchive/archive_digest_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_digest_private.h
@@ -177,6 +177,13 @@
 #else
 #include <windows.h>
 #include <wincrypt.h>
+/* Undefine indirect <wincrypt.h> symbols conflicting with BoringSSL/AWS-LC. */
+#undef X509_NAME
+#undef X509_EXTENSIONS
+#undef PKCS7_ISSUER_AND_SERIAL
+#undef PKCS7_SIGNER_INFO
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
 #define	ARCHIVE_CRYPTO_WINCRYPT 1
 typedef struct {
   int   valid;