Merge topic 'doc-header-only'

2d5f2c9311 Help: Make cmake-buildsystem(7) header-only examples consistent

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10333
diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml
index d19dd74..d024f41 100644
--- a/.gitlab/os-windows.yml
+++ b/.gitlab/os-windows.yml
@@ -35,25 +35,25 @@
     variables:
         VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat"
         VCVARSPLATFORM: "x64"
-        VCVARSVERSION: "14.42.34433"
+        VCVARSVERSION: "14.43.34808"
 
 .windows_vcvarsall_vs2022_x86:
     variables:
         VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat"
         VCVARSPLATFORM: "x86"
-        VCVARSVERSION: "14.42.34433"
+        VCVARSVERSION: "14.43.34808"
 
 .windows_vcvarsall_vs2022_x64_arm64:
     variables:
         VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat"
         VCVARSPLATFORM: "x64_arm64"
-        VCVARSVERSION: "14.42.34433"
+        VCVARSVERSION: "14.43.34808"
 
 .windows_arm64_vcvarsall_vs2022:
     variables:
         VCVARSALL: "${VS170COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat"
         VCVARSPLATFORM: "arm64"
-        VCVARSVERSION: "14.42.34433"
+        VCVARSVERSION: "14.43.34808"
 
 .windows_vs2022_x64_pch:
     extends:
@@ -119,7 +119,7 @@
         CMAKE_CONFIGURATION: windows_vs2022_x64
         CMAKE_GENERATOR: "Visual Studio 17 2022"
         CMAKE_GENERATOR_PLATFORM: "x64"
-        CMAKE_GENERATOR_TOOLSET: "v143,version=14.42.34433"
+        CMAKE_GENERATOR_TOOLSET: "v143,version=14.43.34808"
         CMAKE_CI_NIGHTLY_IGNORE_DEPS: "true"
 
 .windows_vs2019_x64:
@@ -282,7 +282,7 @@
         CMAKE_CONFIGURATION: windows_arm64_vs2022
         CMAKE_GENERATOR: "Visual Studio 17 2022"
         CMAKE_GENERATOR_PLATFORM: "ARM64"
-        CMAKE_GENERATOR_TOOLSET: "v143,version=14.42.34433"
+        CMAKE_GENERATOR_TOOLSET: "v143,version=14.43.34808"
         CMAKE_CI_NIGHTLY_IGNORE_DEPS: "true"
 
 .mingw_osdn_io:
@@ -316,7 +316,7 @@
         - windows-x86_64
         - shell
         - vs2022
-        - msvc-14.42
+        - msvc-14.43
         - nonconcurrent
 
 .windows_x86_64_tags_nonconcurrent_vs2022_arm64:
@@ -325,7 +325,7 @@
         - windows-x86_64
         - shell
         - vs2022
-        - msvc-14.42-arm64
+        - msvc-14.43-arm64
         - nonconcurrent
 
 .windows_x86_64_tags_concurrent_vs2022:
@@ -334,7 +334,7 @@
         - windows-x86_64
         - shell
         - vs2022
-        - msvc-14.42
+        - msvc-14.43
         - concurrent
 
 .windows_x86_64_tags_concurrent_vs2022_android:
@@ -344,7 +344,7 @@
         - shell
         - vs2022
         - vs17-android
-        - msvc-14.42
+        - msvc-14.43
         - concurrent
 
 .windows_x86_64_tags_concurrent_vs2019_android:
@@ -370,7 +370,7 @@
         - windows-arm64
         - shell
         - vs2022
-        - msvc-14.42
+        - msvc-14.43
         - nonconcurrent
 
 .windows_arm64_tags_concurrent_vs2022:
@@ -379,7 +379,7 @@
         - windows-arm64
         - shell
         - vs2022
-        - msvc-14.42
+        - msvc-14.43
         - concurrent
 
 ## Windows-specific scripts
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1a12cb..ca0d5ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # file Copyright.txt or https://cmake.org/licensing for details.
 
-cmake_minimum_required(VERSION 3.13...3.30 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.13...3.31 FATAL_ERROR)
 set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
 set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
 
diff --git a/Help/command/cmake_instrumentation.rst b/Help/command/cmake_instrumentation.rst
index a859ff3..22e77ea 100644
--- a/Help/command/cmake_instrumentation.rst
+++ b/Help/command/cmake_instrumentation.rst
@@ -3,6 +3,11 @@
 
 .. versionadded:: 4.0
 
+.. note::
+
+   This command is only available when experimental support for instrumentation
+   has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
+
 Enables interacting with the
 :manual:`CMake Instrumentation API <cmake-instrumentation(7)>`.
 
diff --git a/Help/command/execute_process.rst b/Help/command/execute_process.rst
index 510059a..c2c7fe3 100644
--- a/Help/command/execute_process.rst
+++ b/Help/command/execute_process.rst
@@ -44,23 +44,31 @@
 
  CMake executes the child process using operating system APIs directly:
 
- * On POSIX platforms, the command line is passed to the
-   child process in an ``argv[]`` style array.
+ * On POSIX platforms, the command line is passed to the child process
+   in an ``argv[]`` style array.  No intermediate shell is executed,
+   so shell operators such as ``>`` are treated as normal arguments.
 
  * On Windows platforms, the command line is encoded as a string such
    that child processes using `CommandLineToArgvW`_ will decode the
-   original arguments.  If the command runs a ``.bat`` or ``.cmd``
-   script, it may receive arguments with extra quoting.
+   original arguments.
 
- * .. versionchanged:: 4.0
-     On Windows platforms, if the command runs a ``.bat`` or ``.cmd`` script,
-     it is automatically executed through the command interpreter, ``cmd /c``.
-     However, paths with spaces may fail if a "short path" is not available.
+   If the command runs a ``.exe``, ``.com``, or other executable,
+   no intermediate command interpreter is executed, so shell operators
+   such as ``>`` are treated as normal arguments.
 
- No intermediate shell is used, so shell operators such as ``>``
- are treated as normal arguments.
- (Use the ``INPUT_*``, ``OUTPUT_*``, and ``ERROR_*`` options to
- redirect stdin, stdout, and stderr.)
+   If the command runs a ``.bat`` or ``.cmd`` script, it is executed
+   through the ``cmd`` command interpreter.  The command interpreter
+   does not use `CommandLineToArgvW`_, so some arguments may be received
+   by the script with extra quoting.
+
+   .. versionchanged:: 4.0
+     ``.bat`` and ``.cmd`` scripts are now explicitly executed through the
+     command interpreter by prepending ``cmd /c call`` to the command line.
+     Previously, they were implicitly executed through ``cmd /c``, without
+     ``call``, by undocumented behavior of `CreateProcessW`_.
+
+ Use the ``INPUT_*``, ``OUTPUT_*``, and ``ERROR_*`` options to
+ redirect stdin, stdout, and stderr.
 
  For **sequential execution** of multiple commands use multiple
  ``execute_process`` calls each with a single ``COMMAND`` argument.
@@ -205,3 +213,4 @@
     :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL` is ignored.
 
 .. _`CommandLineToArgvW`: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw
+.. _`CreateProcessW`: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst
index ba046fa..fea5e74 100644
--- a/Help/command/find_library.rst
+++ b/Help/command/find_library.rst
@@ -52,8 +52,10 @@
 directory at a time and search for all names in it.
 
 Each library name given to the ``NAMES`` option is first considered
-as a library file name and then considered with platform-specific
-prefixes (e.g. ``lib``) and suffixes (e.g. ``.so``).  Therefore one
+as is, if it contains a library suffix, and then considered with
+platform-specific prefixes (e.g. ``lib``) and suffixes (e.g. ``.so``),
+as defined by the variables :variable:`CMAKE_FIND_LIBRARY_PREFIXES` and
+:variable:`CMAKE_FIND_LIBRARY_SUFFIXES`. Therefore one
 may specify library file names such as ``libfoo.a`` directly.
 This can be used to locate static libraries on UNIX-like systems.
 
diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst
index 064e96f..ab01307 100644
--- a/Help/command/target_link_libraries.rst
+++ b/Help/command/target_link_libraries.rst
@@ -120,9 +120,6 @@
   Additionally, a generator expression may be used as a fragment of
   any of the above items, e.g. ``foo$<1:_d>``.
 
-  Note that generator expressions will not be used in OLD handling of
-  policy :policy:`CMP0003` or policy :policy:`CMP0004`.
-
 * A ``debug``, ``optimized``, or ``general`` keyword immediately followed
   by another ``<item>``.  The item following such a keyword will be used
   only for the corresponding build configuration.  The ``debug`` keyword
@@ -182,8 +179,10 @@
 linked to this target will appear on the link line for the other
 target too.  This transitive "link interface" is stored in the
 :prop_tgt:`INTERFACE_LINK_LIBRARIES` target property and may be overridden
-by setting the property directly.  When :policy:`CMP0022` is not set to
-``NEW``, transitive linking is built in but may be overridden by the
+by setting the property directly.
+
+In CMake versions prior to 4.0, if :policy:`CMP0022` is not set to ``NEW``,
+transitive linking is built in but may be overridden by the
 :prop_tgt:`LINK_INTERFACE_LIBRARIES` property.  Calls to other signatures
 of this command may set the property making any libraries linked
 exclusively by this signature private.
@@ -191,6 +190,9 @@
 Libraries for a Target and/or its Dependents (Legacy)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+This signature is for compatibility only.  Prefer the ``PUBLIC`` or
+``PRIVATE`` keywords instead.
+
 .. code-block:: cmake
 
   target_link_libraries(<target>
@@ -200,44 +202,32 @@
 The ``LINK_PUBLIC`` and ``LINK_PRIVATE`` modes can be used to specify both
 the link dependencies and the link interface in one command.
 
-This signature is for compatibility only.  Prefer the ``PUBLIC`` or
-``PRIVATE`` keywords instead.
-
 Libraries and targets following ``LINK_PUBLIC`` are linked to, and are
-made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`.  If policy
-:policy:`CMP0022` is not ``NEW``, they are also made part of the
-:prop_tgt:`LINK_INTERFACE_LIBRARIES`.  Libraries and targets following
-``LINK_PRIVATE`` are linked to, but are not made part of the
-:prop_tgt:`INTERFACE_LINK_LIBRARIES` (or :prop_tgt:`LINK_INTERFACE_LIBRARIES`).
+made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`.
+
+In CMake versions prior to 4.0, if policy :policy:`CMP0022` is not ``NEW``,
+they are also made part of the :prop_tgt:`LINK_INTERFACE_LIBRARIES`.
+Libraries and targets following ``LINK_PRIVATE`` are linked to, but are
+not made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+(or :prop_tgt:`LINK_INTERFACE_LIBRARIES`).
 
 Libraries for Dependents Only (Legacy)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+This signature is for compatibility only.  Prefer the ``INTERFACE`` mode
+instead.
+
 .. code-block:: cmake
 
   target_link_libraries(<target> LINK_INTERFACE_LIBRARIES <item>...)
 
 The ``LINK_INTERFACE_LIBRARIES`` mode appends the libraries to the
 :prop_tgt:`INTERFACE_LINK_LIBRARIES` target property instead of using them
-for linking.  If policy :policy:`CMP0022` is not ``NEW``, then this mode
-also appends libraries to the :prop_tgt:`LINK_INTERFACE_LIBRARIES` and its
-per-configuration equivalent.
+for linking.
 
-This signature is for compatibility only.  Prefer the ``INTERFACE`` mode
-instead.
-
-Libraries specified as ``debug`` are wrapped in a generator expression to
-correspond to debug builds.  If policy :policy:`CMP0022` is
-not ``NEW``, the libraries are also appended to the
-:prop_tgt:`LINK_INTERFACE_LIBRARIES_DEBUG <LINK_INTERFACE_LIBRARIES_<CONFIG>>`
-property (or to the properties corresponding to configurations listed in
-the :prop_gbl:`DEBUG_CONFIGURATIONS` global property if it is set).
-Libraries specified as ``optimized`` are appended to the
-:prop_tgt:`INTERFACE_LINK_LIBRARIES` property.  If policy :policy:`CMP0022`
-is not ``NEW``, they are also appended to the
-:prop_tgt:`LINK_INTERFACE_LIBRARIES` property.  Libraries specified as
-``general`` (or without any keyword) are treated as if specified for both
-``debug`` and ``optimized``.
+In CMake versions prior to 4.0, if policy :policy:`CMP0022` is not ``NEW``,
+then this mode also appends libraries to the
+:prop_tgt:`LINK_INTERFACE_LIBRARIES` and its per-configuration equivalent.
 
 .. _`Linking Object Libraries`:
 
diff --git a/Help/dev/maint.rst b/Help/dev/maint.rst
index 2f4babc..24ddb9a 100644
--- a/Help/dev/maint.rst
+++ b/Help/dev/maint.rst
@@ -78,7 +78,7 @@
 .. code-block:: shell
 
   git fetch origin
-  git checkout -b release-$ver origin/release
+  git switch -c release-$ver origin/release
 
 Merge the ``$topic`` branch into the local ``release-$ver`` branch, making
 sure to include a ``Merge-request: !xxxx`` footer in the commit message:
@@ -91,7 +91,7 @@
 
 .. code-block:: shell
 
-  git checkout master
+  git switch master
   git pull
   git merge --no-ff release-$ver
 
@@ -180,7 +180,7 @@
 
 .. code-block:: shell
 
-  git checkout -b doc-$ver-relnotes
+  git switch -c doc-$ver-relnotes
 
 Run the `consolidate-relnotes.bash`_ script:
 
@@ -236,7 +236,7 @@
 
 .. code-block:: shell
 
-  git checkout -b release-$ver origin/master
+  git switch -c release-$ver origin/master
 
 Remove the development branch release note infrastructure:
 
@@ -278,7 +278,7 @@
 
 .. code-block:: shell
 
-  git checkout master
+  git switch master
   git pull
   git merge --no-ff release-$ver
 
@@ -287,7 +287,7 @@
 
 .. code-block:: shell
 
-  git checkout origin/master -- \
+  git restore -s origin/master -- \
     Source/CMakeVersion.cmake Help/release/dev/0-sample-topic.rst
   sed -i $'/^Releases/ i\\\n.. include:: dev.txt\\\n' Help/release/index.rst
 
diff --git a/Help/manual/cmake-instrumentation.7.rst b/Help/manual/cmake-instrumentation.7.rst
index 3a70843..7b2d1e6 100644
--- a/Help/manual/cmake-instrumentation.7.rst
+++ b/Help/manual/cmake-instrumentation.7.rst
@@ -12,6 +12,11 @@
 Introduction
 ============
 
+.. note::
+
+   This feature is only available when experimental support for instrumentation
+   has been enabled by the ``CMAKE_EXPERIMENTAL_INSTRUMENTATION`` gate.
+
 The CMake Instrumentation API allows for the collection of timing data, target
 information and system diagnostic information during the configure, generate,
 build, test and install steps for a CMake project.
@@ -243,7 +248,7 @@
     always ``1``.
 
   ``command``
-    The full command executed.
+    The full command executed. Excluded when ``role`` is ``build``.
 
   ``result``
     The exit-value of the command, an integer.
@@ -251,13 +256,17 @@
   ``role``
     The type of command executed, which will be one of the following values:
 
-    * ``compile``
-    * ``link``
-    * ``custom``
-    * ``cmakeBuild``
-    * ``install``
-    * ``ctest``
-    * ``test``
+    * ``configure``: the CMake configure step
+    * ``generate``: the CMake generate step
+    * ``compile``: an individual compile step invoked during the build
+    * ``link``: an individual link step invoked during the build
+    * ``custom``: an individual custom command invoked during the build
+    * ``build``: a complete ``make`` or ``ninja`` invocation. Only generated if ``preBuild`` or ``postBuild`` hooks are enabled.
+    * ``cmakeBuild``: a complete ``cmake --build`` invocation
+    * ``cmakeInstall``: a complete ``cmake --install`` invocation
+    * ``install``: an individual ``cmake -P cmake_install.cmake`` invocation
+    * ``ctest``: a complete ``ctest`` invocation
+    * ``test``: a single test executed by CTest
 
   ``target``
     The CMake target associated with the command. Only included when ``role`` is
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 0165d6a..bf0933a 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -34,10 +34,10 @@
 
 .. code-block:: cmake
 
-  cmake_minimum_required(VERSION 3.10...3.31)
+  cmake_minimum_required(VERSION 3.10...4.0)
 
 This uses the ``<min>...<max>`` syntax to enable the ``NEW`` behaviors
-of policies introduced in CMake 3.31 and earlier while only requiring a
+of policies introduced in CMake 4.0 and earlier while only requiring a
 minimum version of CMake 3.10.  The project is expected to work with
 both the ``OLD`` and ``NEW`` behaviors of policies introduced between
 those versions.
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
new file mode 100644
index 0000000..e4cc01e
--- /dev/null
+++ b/Help/release/dev/0-sample-topic.rst
@@ -0,0 +1,7 @@
+0-sample-topic
+--------------
+
+* This is a sample release note for the change in a topic.
+  Developers should add similar notes for each topic branch
+  making a noteworthy change.  Each document should be named
+  and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index b083cf5..7c44090 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -7,6 +7,8 @@
   This file should include the adjacent "dev.txt" file
   in development versions but not in release versions.
 
+.. include:: dev.txt
+
 Releases
 ========
 
diff --git a/Modules/UseJava/javaTargets.cmake.in b/Modules/UseJava/javaTargets.cmake.in
index 11f1f06..4aa6560 100644
--- a/Modules/UseJava/javaTargets.cmake.in
+++ b/Modules/UseJava/javaTargets.cmake.in
@@ -1,5 +1,5 @@
 cmake_policy(PUSH)
-cmake_policy(VERSION 2.8.12...3.30)
+cmake_policy(VERSION 2.8.12...3.31)
 
 #----------------------------------------------------------------
 # Generated CMake Java target import file.
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 249574f..bf50f8c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,8 +1,8 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 4)
 set(CMake_VERSION_MINOR 0)
-set(CMake_VERSION_PATCH 0)
-set(CMake_VERSION_RC 0)
+set(CMake_VERSION_PATCH 20250213)
+#set(CMake_VERSION_RC 0)
 set(CMake_VERSION_IS_DIRTY 0)
 
 # Start with the full version number used in tags.  It has no dev info.
diff --git a/Source/Checks/Curses/CMakeLists.txt b/Source/Checks/Curses/CMakeLists.txt
index 1f04bd2..255143d 100644
--- a/Source/Checks/Curses/CMakeLists.txt
+++ b/Source/Checks/Curses/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.13...3.30 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.13...3.31 FATAL_ERROR)
 project(CheckCurses C)
 
 set(CURSES_NEED_NCURSES TRUE)
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 750c09d..649b88f 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -166,16 +166,7 @@
       status.SetError(" given COMMAND argument with no value.");
       return false;
     }
-#ifdef _WIN32
-    cmsys::Status shortPathRes = cmSystemTools::MaybePrependCmdExe(cmd);
-    if (!shortPathRes) {
-      status.GetMakefile().IssueMessage(
-        MessageType::WARNING,
-        cmStrCat("Conversion of COMMAND:\n  ", cmd[2], '\n',
-                 "to a short path without spaces failed:\n  ",
-                 shortPathRes.GetString()));
-    }
-#endif
+    cmSystemTools::MaybePrependCmdExe(cmd);
   }
 
   // Parse the timeout string.
diff --git a/Source/cmExportCMakeConfigGenerator.cxx b/Source/cmExportCMakeConfigGenerator.cxx
index bb9de54..257ea26 100644
--- a/Source/cmExportCMakeConfigGenerator.cxx
+++ b/Source/cmExportCMakeConfigGenerator.cxx
@@ -173,7 +173,7 @@
   // Isolate the file policy level.
   // Support CMake versions as far back as the
   // RequiredCMakeVersion{Major,Minor,Patch}, but also support using NEW
-  // policy settings for up to CMake 3.30 (this upper limit may be reviewed
+  // policy settings for up to CMake 3.31 (this upper limit may be reviewed
   // and increased from time to time). This reduces the opportunity for CMake
   // warnings when an older export file is later used with newer CMake
   // versions.
@@ -182,7 +182,7 @@
         "cmake_policy(VERSION "
      << this->RequiredCMakeVersionMajor << '.'
      << this->RequiredCMakeVersionMinor << '.'
-     << this->RequiredCMakeVersionPatch << "...3.30)\n";
+     << this->RequiredCMakeVersionPatch << "...3.31)\n";
   /* clang-format on */
 }
 
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 953c433..8733e3c 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -356,14 +356,16 @@
   {
     if (this->valid()) {
       long to_skip = this->count;
-      long index_to_remove = 0;
+      size_t index_to_remove = 0;
       for (auto const& path : entries) {
         if (path == this->value && --to_skip == 0) {
           break;
         }
         ++index_to_remove;
       }
-      entries.erase(entries.begin() + index_to_remove);
+      if (index_to_remove < entries.size() && to_skip == 0) {
+        entries.erase(entries.begin() + index_to_remove);
+      }
     }
   }
 
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index cd1938e..63a313c 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -2022,7 +2022,7 @@
   cmsys::Glob glob;
   glob.RecurseOff();
   if (glob.FindFiles(
-        cmStrCat(cmSystemTools::GetFilenamePath(fileName), "/"_s,
+        cmStrCat(cmSystemTools::GetFilenamePath(fileName), '/',
                  cmSystemTools::GetFilenameWithoutExtension(fileName),
                  "@*.[Cc][Pp][Ss]"_s))) {
 
diff --git a/Source/cmInstrumentation.cxx b/Source/cmInstrumentation.cxx
index 87f59a8..6dffc4c 100644
--- a/Source/cmInstrumentation.cxx
+++ b/Source/cmInstrumentation.cxx
@@ -365,7 +365,9 @@
   Json::Value commandInfo(Json::objectValue);
   std::string command_str = GetCommandStr(command);
 
-  root["command"] = command_str;
+  if (!command_str.empty()) {
+    root["command"] = command_str;
+  }
   root["version"] = 1;
 
   // Pre-Command
@@ -533,8 +535,15 @@
  */
 int cmInstrumentation::CollectTimingAfterBuild(int ppid)
 {
-  while (0 == uv_kill(ppid, 0)) {
-    cmSystemTools::Delay(100);
+  std::function<int()> waitForBuild = [ppid]() -> int {
+    while (0 == uv_kill(ppid, 0)) {
+      cmSystemTools::Delay(100);
+    };
+    return 0;
   };
-  return this->CollectTimingData(cmInstrumentationQuery::Hook::PostBuild);
+  int ret = this->InstrumentCommand(
+    "build", {}, [waitForBuild]() { return waitForBuild(); }, cm::nullopt,
+    cm::nullopt, false);
+  this->CollectTimingData(cmInstrumentationQuery::Hook::PostBuild);
+  return ret;
 }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d98c59b..dd1d7cd 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4034,14 +4034,14 @@
   }
 
   // Deprecate old policies.
-  if (status == cmPolicies::OLD && id <= cmPolicies::CMP0139 &&
+  if (status == cmPolicies::OLD && id <= cmPolicies::CMP0142 &&
       !(this->GetCMakeInstance()->GetIsInTryCompile() &&
         (
           // Policies set by cmCoreTryCompile::TryCompileCode.
           id == cmPolicies::CMP0083 || id == cmPolicies::CMP0091 ||
           id == cmPolicies::CMP0104 || id == cmPolicies::CMP0123 ||
           id == cmPolicies::CMP0126 || id == cmPolicies::CMP0128 ||
-          id == cmPolicies::CMP0136)) &&
+          id == cmPolicies::CMP0136 || id == cmPolicies::CMP0141)) &&
       (!this->IsSet("CMAKE_WARN_DEPRECATED") ||
        this->IsOn("CMAKE_WARN_DEPRECATED"))) {
     this->IssueMessage(MessageType::DEPRECATION_WARNING,
diff --git a/Source/cmPackageInfoReader.cxx b/Source/cmPackageInfoReader.cxx
index a5349ca..82f2cb8 100644
--- a/Source/cmPackageInfoReader.cxx
+++ b/Source/cmPackageInfoReader.cxx
@@ -376,7 +376,7 @@
   //   - the input is a JSON object
   //   - the input has a "cps_version" that we (in theory) know how to parse
   Json::Value data = ReadJson(path);
-  if (!data.isObject() || !CheckSchemaVersion(data)) {
+  if (!data.isObject() || (!parent && !CheckSchemaVersion(data))) {
     return nullptr;
   }
 
@@ -527,6 +527,13 @@
   cmMakefile* makefile, cmTarget* target, Json::Value const& data,
   std::string const& package, cm::string_view configuration) const
 {
+  // Add configuration (if applicable).
+  if (!configuration.empty()) {
+    target->AppendProperty("IMPORTED_CONFIGURATIONS",
+                           cmSystemTools::UpperCase(configuration),
+                           makefile->GetBacktrace());
+  }
+
   // Add compile and link features.
   for (std::string const& def : ReadList(data, "compile_features")) {
     AddCompileFeature(makefile, target, configuration, def);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 8e9deb1..8036358 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -795,38 +795,31 @@
   return sz;
 }
 
-cmsys::Status cmSystemTools::MaybePrependCmdExe(
-  std::vector<std::string>& cmdLine)
+void cmSystemTools::MaybePrependCmdExe(std::vector<std::string>& cmdLine)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  cmsys::Status status;
   if (!cmdLine.empty()) {
     std::string& applicationName = cmdLine.at(0);
     static cmsys::RegularExpression const winCmdRegex(
       "\\.([Bb][Aa][Tt]|[Cc][Mm][Dd])$");
     cmsys::RegularExpressionMatch winCmdMatch;
     if (winCmdRegex.find(applicationName.c_str(), winCmdMatch)) {
+      // Wrap `.bat` and `.cmd` commands with `cmd /c call`.
       std::vector<std::string> output;
-      output.reserve(cmdLine.size() + 2);
+      output.reserve(cmdLine.size() + 3);
       output.emplace_back(cmSystemTools::GetComspec());
       output.emplace_back("/c");
+      output.emplace_back("call");
       // Convert the batch file path to use backslashes for cmd.exe to parse.
       std::replace(applicationName.begin(), applicationName.end(), '/', '\\');
-      if (applicationName.find(' ') != std::string::npos) {
-        // Convert the batch file path to a short path to avoid spaces.
-        // Otherwise, cmd.exe may not handle arguments with spaces.
-        status = cmSystemTools::GetShortPath(applicationName, applicationName);
-      }
-      output.push_back(applicationName);
+      output.emplace_back(applicationName);
       std::move(cmdLine.begin() + 1, cmdLine.end(),
                 std::back_inserter(output));
       cmdLine = std::move(output);
     }
   }
-  return status;
 #else
   static_cast<void>(cmdLine);
-  return cmsys::Status::Success();
 #endif
 }
 
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 60a7095..e2720ca 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -235,23 +235,18 @@
                                            std::string const& destination);
 
   /**
-   *  According to the CreateProcessW documentation which is the underlying
-   *  function for all RunProcess calls:
+   * According to the CreateProcessW documentation:
    *
-   *  "To run a batch file, you must start the command interpreter; set"
-   *  "lpApplicationName to cmd.exe and set lpCommandLine to the following"
-   *  "arguments: /c plus the name of the batch file."
+   *   To run a batch file, you must start the command interpreter; set
+   *   lpApplicationName to cmd.exe and set lpCommandLine to the following
+   *   arguments: /c plus the name of the batch file.
    *
-   *  we should to take care of the correctness of the command line when
-   *  attempting to execute the batch files.
-   *
-   *  Also cmd.exe is unable to parse batch file names correctly if they
-   *  contain spaces. This function uses cmSystemTools::GetShortPath
-   *  conversion to suppress this behavior, and returns its status.
+   * Additionally, "cmd /c" does not always parse batch file names correctly
+   * if they contain spaces, but using "cmd /c call" seems to work.
    *
    *  The function is noop on platforms different from the pure WIN32 one.
    */
-  static cmsys::Status MaybePrependCmdExe(std::vector<std::string>& cmdLine);
+  static void MaybePrependCmdExe(std::vector<std::string>& cmdLine);
 
   /**
    * Run a single executable command
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 25a3357..78d4655 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3854,7 +3854,8 @@
 
   std::string cachePath = FindCacheFile(dir);
   if (!this->LoadCache(cachePath)) {
-    std::cerr << "Error: could not load cache\n";
+    std::cerr
+      << "Error: not a CMake build directory (missing CMakeCache.txt)\n";
     return 1;
   }
   cmValue cachedGenerator = this->State->GetCacheEntryValue("CMAKE_GENERATOR");
@@ -3983,7 +3984,8 @@
 
   std::string cachePath = FindCacheFile(dir);
   if (!this->LoadCache(cachePath)) {
-    std::cerr << "Error: could not load cache\n";
+    std::cerr
+      << "Error: not a CMake build directory (missing CMakeCache.txt)\n";
     return false;
   }
   cmValue genName = this->State->GetCacheEntryValue("CMAKE_GENERATOR");
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index c679c48..aca0324 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3441,7 +3441,6 @@
                                             this->CurrentPositionInFile + 1);
   }
   uint64_t NumberOfSockets = PhysicalIDs.size();
-  NumberOfSockets = std::max(NumberOfSockets, (uint64_t)1);
   // Physical ids returned by Linux don't distinguish cores.
   // We want to record the total number of cores in this->NumberOfPhysicalCPU
   // (checking only the first proc)
@@ -3451,9 +3450,11 @@
     Cores = this->ExtractValueFromCpuInfoFile(buffer, "ncpus probed");
   }
   auto NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
-  NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u);
-  this->NumberOfPhysicalCPU =
-    NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
+  // If either one is 0, will be assigned with NumberOfLogicalCPU or 1 below.
+  if (NumberOfSockets > 0 && NumberOfCoresPerSocket > 0) {
+    this->NumberOfPhysicalCPU =
+      NumberOfCoresPerSocket * (unsigned int)NumberOfSockets;
+  }
 
 #else
   // For systems which do not have "physical id" entries, neither "cpu cores"
@@ -3465,10 +3466,11 @@
 #endif
   // gotta have one, and if this is 0 then we get a / by 0n
   // better to have a bad answer than a crash
-  if (this->NumberOfPhysicalCPU <= 0) {
-    this->NumberOfPhysicalCPU = 1;
-  }
-  if (this->NumberOfLogicalCPU == 0) {
+  if (this->NumberOfPhysicalCPU == 0 && this->NumberOfLogicalCPU == 0) {
+    this->NumberOfPhysicalCPU = this->NumberOfLogicalCPU = 1;
+  } else if (this->NumberOfPhysicalCPU == 0) {
+    this->NumberOfPhysicalCPU = this->NumberOfLogicalCPU;
+  } else if (this->NumberOfLogicalCPU == 0) {
     this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU;
   }
   // LogicalProcessorsPerPhysical>1 => SMT.
diff --git a/Tests/CMakeLib/testUVPatches.cxx b/Tests/CMakeLib/testUVPatches.cxx
index 06f8d1f..e5d137b 100644
--- a/Tests/CMakeLib/testUVPatches.cxx
+++ b/Tests/CMakeLib/testUVPatches.cxx
@@ -28,6 +28,7 @@
   ASSERT_EQUAL(r, 0);
   uv_run(loop, UV_RUN_DEFAULT);
   uv_fs_req_cleanup(&tempDirReq);
+  uv_loop_close(loop);
   if (!cmSystemTools::FileIsDirectory(tempDir)) {
     std::cout << "cmSystemTools::MakeTempDirectory did not create \""
               << tempDir << '\n';
diff --git a/Tests/FindPackageCpsTest/cps/foo-relative@default.cps b/Tests/FindPackageCpsTest/cps/foo-relative@default.cps
index 19a55dd..c9e8d4f 100644
--- a/Tests/FindPackageCpsTest/cps/foo-relative@default.cps
+++ b/Tests/FindPackageCpsTest/cps/foo-relative@default.cps
@@ -1,5 +1,4 @@
 {
-  "cps_version": "0.13",
   "name": "Foo",
   "configuration": "default",
   "components": {
diff --git a/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt b/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt
index fa3adc8..1eebfc6 100644
--- a/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt
+++ b/Tests/RunCMake/CommandLine/build-invalid-target-syntax-stderr.txt
@@ -1 +1 @@
-^Error: could not load cache
+^Error: not a CMake build directory \(missing CMakeCache\.txt\)$
diff --git a/Tests/RunCMake/CommandLine/build-no-cache-stderr.txt b/Tests/RunCMake/CommandLine/build-no-cache-stderr.txt
index 40dd3c0..1eebfc6 100644
--- a/Tests/RunCMake/CommandLine/build-no-cache-stderr.txt
+++ b/Tests/RunCMake/CommandLine/build-no-cache-stderr.txt
@@ -1 +1 @@
-^Error: could not load cache$
+^Error: not a CMake build directory \(missing CMakeCache\.txt\)$
diff --git a/Tests/RunCMake/Instrumentation/check-make-program-hooks.cmake b/Tests/RunCMake/Instrumentation/check-make-program-hooks.cmake
index 60b2f7b..239af3b 100644
--- a/Tests/RunCMake/Instrumentation/check-make-program-hooks.cmake
+++ b/Tests/RunCMake/Instrumentation/check-make-program-hooks.cmake
@@ -33,3 +33,13 @@
 if (NOT dataDirClean)
   string(APPEND RunCMake_TEST_FAILED "Snippet files not fully removed post build\n")
 endif()
+
+file(READ ${v1}/postBuild.hook postBuildErrors)
+if (NOT postBuildErrors MATCHES "^$")
+  string(APPEND RunCMake_TEST_FAILED "Errors found in data during postBuild hook:\n${postBuildErrors}\n")
+endif()
+
+file(READ ${v1}/preBuild.hook preBuildErrors)
+if (NOT preBuildErrors MATCHES "^$")
+  string(APPEND RunCMake_TEST_FAILED "Errors found in data during preBuild hook:\n${preBuildErrors}\n")
+endif()
diff --git a/Tests/RunCMake/Instrumentation/hook.cmake b/Tests/RunCMake/Instrumentation/hook.cmake
index cef088d..a139a37 100644
--- a/Tests/RunCMake/Instrumentation/hook.cmake
+++ b/Tests/RunCMake/Instrumentation/hook.cmake
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.30)
 
 include(${CMAKE_CURRENT_LIST_DIR}/json.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/verify-snippet.cmake)
 # Test CALLBACK script. Prints output information and verifies index file
 # Called as: cmake -P hook.cmake [CheckForStaticQuery?] [index.json]
 set(index ${CMAKE_ARGV4})
@@ -19,7 +20,7 @@
   return(PROPAGATE ERROR_MESSAGE)
 endfunction()
 
-function(has_key key json)
+function(has_key_index key json)
   cmake_parse_arguments(ARG "UNEXPECTED" "" "" ${ARGN})
   unset(missingKey)
   string(JSON ${key} ERROR_VARIABLE missingKey GET "${json}" ${key})
@@ -28,13 +29,13 @@
   elseif(ARG_UNEXPECTED AND missingKey MATCHES NOTFOUND)
     add_error("\nUnexpected key \"${key}\" in index:\n${json}")
   endif()
-  return(PROPAGATE RunCMake_TEST_FAILED ${key})
+  return(PROPAGATE ERROR_MESSAGE ${key})
 endfunction()
 
-has_key(version "${contents}")
-has_key(buildDir "${contents}")
-has_key(dataDir "${contents}")
-has_key(snippets "${contents}")
+has_key_index(version "${contents}")
+has_key_index(buildDir "${contents}")
+has_key_index(dataDir "${contents}")
+has_key_index(snippets "${contents}")
 
 if (NOT version EQUAL 1)
     add_error("Version must be 1, got: ${version}")
@@ -47,32 +48,34 @@
   if (NOT EXISTS ${dataDir}/${filename})
     add_error("Listed snippet: ${dataDir}/${filename} does not exist")
   endif()
+  read_json(${dataDir}/${filename} snippet_contents)
+  verify_snippet(${dataDir}/${filename} "${snippet_contents}")
 endforeach()
 
-has_key(staticSystemInformation "${contents}" ${hasStaticInfo})
-has_key(OSName "${staticSystemInformation}" ${hasStaticInfo})
-has_key(OSPlatform "${staticSystemInformation}" ${hasStaticInfo})
-has_key(OSRelease "${staticSystemInformation}" ${hasStaticInfo})
-has_key(OSVersion "${staticSystemInformation}" ${hasStaticInfo})
-has_key(familyId "${staticSystemInformation}" ${hasStaticInfo})
-has_key(hostname "${staticSystemInformation}" ${hasStaticInfo})
-has_key(is64Bits "${staticSystemInformation}" ${hasStaticInfo})
-has_key(modelId "${staticSystemInformation}" ${hasStaticInfo})
-has_key(numberOfLogicalCPU "${staticSystemInformation}" ${hasStaticInfo})
-has_key(numberOfPhysicalCPU "${staticSystemInformation}" ${hasStaticInfo})
-has_key(processorAPICID "${staticSystemInformation}" ${hasStaticInfo})
-has_key(processorCacheSize "${staticSystemInformation}" ${hasStaticInfo})
-has_key(processorClockFrequency "${staticSystemInformation}" ${hasStaticInfo})
-has_key(processorName "${staticSystemInformation}" ${hasStaticInfo})
-has_key(totalPhysicalMemory "${staticSystemInformation}" ${hasStaticInfo})
-has_key(totalVirtualMemory "${staticSystemInformation}" ${hasStaticInfo})
-has_key(vendorID "${staticSystemInformation}" ${hasStaticInfo})
-has_key(vendorString "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(staticSystemInformation "${contents}" ${hasStaticInfo})
+has_key_index(OSName "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(OSPlatform "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(OSRelease "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(OSVersion "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(familyId "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(hostname "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(is64Bits "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(modelId "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(numberOfLogicalCPU "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(numberOfPhysicalCPU "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(processorAPICID "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(processorCacheSize "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(processorClockFrequency "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(processorName "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(totalPhysicalMemory "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(totalVirtualMemory "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(vendorID "${staticSystemInformation}" ${hasStaticInfo})
+has_key_index(vendorString "${staticSystemInformation}" ${hasStaticInfo})
+
+get_filename_component(dataDir ${index} DIRECTORY)
+get_filename_component(v1 ${dataDir} DIRECTORY)
+file(WRITE ${v1}/${hook}.hook "${ERROR_MESSAGE}")
 
 if (NOT ERROR_MESSAGE MATCHES "^$")
   message(FATAL_ERROR ${ERROR_MESSAGE})
 endif()
-
-get_filename_component(dataDir ${index} DIRECTORY)
-get_filename_component(v1 ${dataDir} DIRECTORY)
-file(TOUCH ${v1}/${hook}.hook)
diff --git a/Tests/RunCMake/Instrumentation/verify-snippet.cmake b/Tests/RunCMake/Instrumentation/verify-snippet.cmake
index d64f686..ec997e3 100644
--- a/Tests/RunCMake/Instrumentation/verify-snippet.cmake
+++ b/Tests/RunCMake/Instrumentation/verify-snippet.cmake
@@ -2,12 +2,13 @@
 
 function(add_error error)
   string(APPEND RunCMake_TEST_FAILED " ${error}\n")
-  return(PROPAGATE RunCMake_TEST_FAILED)
+  string(APPEND ERROR_MESSAGE " ${error}\n")
+  return(PROPAGATE RunCMake_TEST_FAILED ERROR_MESSAGE)
 endfunction()
 
 function(snippet_error snippet error)
   add_error("Error in snippet file ${snippet}:\n${error}")
-  return(PROPAGATE RunCMake_TEST_FAILED)
+  return(PROPAGATE RunCMake_TEST_FAILED ERROR_MESSAGE)
 endfunction()
 
 function(has_key snippet json key)
@@ -15,7 +16,7 @@
   if (NOT missingKey MATCHES NOTFOUND)
     snippet_error("${snippet}" "Missing ${key}")
   endif()
-  return(PROPAGATE RunCMake_TEST_FAILED)
+  return(PROPAGATE RunCMake_TEST_FAILED ERROR_MESSAGE)
 endfunction()
 
 function(has_not_key snippet json key)
@@ -23,14 +24,16 @@
   if (missingKey MATCHES NOTFOUND)
     snippet_error("${snippet}" "Has unexpected ${key}")
   endif()
-  return(PROPAGATE RunCMake_TEST_FAILED)
+  return(PROPAGATE RunCMake_TEST_FAILED ERROR_MESSAGE)
 endfunction()
 
 function(snippet_has_fields snippet contents)
   get_filename_component(filename "${snippet}" NAME)
-  has_key("${snippet}" "${contents}" command)
   has_key("${snippet}" "${contents}" role)
   has_key("${snippet}" "${contents}" result)
+  if (NOT filename MATCHES "^build-*")
+    has_key("${snippet}" "${contents}" command)
+  endif()
   if (filename MATCHES "^link-*")
     has_key("${snippet}" "${contents}" target)
     has_key("${snippet}" "${contents}" outputs)
@@ -72,7 +75,7 @@
       has_not_key("${snippet}" ${dynamicSystemInfo} beforeHostMemoryUsed)
     endif()
   endif()
-  return(PROPAGATE RunCMake_TEST_FAILED)
+  return(PROPAGATE RunCMake_TEST_FAILED ERROR_MESSAGE)
 endfunction()
 
 function(snippet_valid_timing contents)
@@ -84,7 +87,7 @@
   if (duration LESS 0)
     snippet_error("${snippet}" "Negative duration: ${end}")
   endif()
-  return(PROPAGATE RunCMake_TEST_FAILED)
+  return(PROPAGATE RunCMake_TEST_FAILED ERROR_MESSAGE)
 endfunction()
 
 function(verify_snippet snippet contents)
@@ -108,5 +111,5 @@
       snippet_error("${snippet}" "outputs and outputSizes do not match")
     endif()
   endif()
-  return(PROPAGATE RunCMake_TEST_FAILED role)
+  return(PROPAGATE ERROR_MESSAGE RunCMake_TEST_FAILED role)
 endfunction()
diff --git a/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-OLD-stderr.txt b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-OLD-stderr.txt
new file mode 100644
index 0000000..92ec2d4
--- /dev/null
+++ b/Tests/RunCMake/MSVCDebugInformationFormat/CMP0141-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0141-OLD\.cmake:[0-9]+ \(cmake_policy\):
+  The OLD behavior for policy CMP0141 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\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom-CMP0141-OLD-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom-CMP0141-OLD-stderr.txt
new file mode 100644
index 0000000..ae26054
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom-CMP0141-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at PchReuseFrom-CMP0141-OLD\.cmake:[0-9]+ \(cmake_policy\):
+  The OLD behavior for policy CMP0141 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\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/XcodeProject/SearchPaths-stderr.txt b/Tests/RunCMake/XcodeProject/SearchPaths-stderr.txt
new file mode 100644
index 0000000..74abd7d
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/SearchPaths-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at SearchPaths\.cmake:[0-9]+ \(cmake_policy\):
+  The OLD behavior for policy CMP0142 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\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
index be2c652..9124afa 100644
--- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake
+++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
@@ -63,11 +63,7 @@
   run_cmake_command(WindowsNoExtension-build ${CMAKE_COMMAND} --build . --config Debug --target RunScript)
 endif()
 
-if(CMAKE_HOST_WIN32
-    # By default, only C: has short paths enabled.
-    # Since querying with `fsutil 8dot3name query C:`
-    # requires admin, just test the drive letter.
-    AND RunCMake_SOURCE_DIR MATCHES "^[Cc]:")
+if(CMAKE_HOST_WIN32)
   run_cmake_command(WindowsBatch ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/WindowsBatch.cmake)
 endif()
 
diff --git a/Tests/RunCMake/return/CMP0140-OLD-stderr.txt b/Tests/RunCMake/return/CMP0140-OLD-stderr.txt
new file mode 100644
index 0000000..bcd37c2
--- /dev/null
+++ b/Tests/RunCMake/return/CMP0140-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0140-OLD\.cmake:[0-9]+ \(cmake_policy\):
+  The OLD behavior for policy CMP0140 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\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt
index 64f9a3f..0426da6 100644
--- a/Utilities/Doxygen/CMakeLists.txt
+++ b/Utilities/Doxygen/CMakeLists.txt
@@ -3,7 +3,7 @@
 
 if(NOT CMake_SOURCE_DIR)
   set(CMakeDeveloperReference_STANDALONE 1)
-  cmake_minimum_required(VERSION 3.13...3.30 FATAL_ERROR)
+  cmake_minimum_required(VERSION 3.13...3.31 FATAL_ERROR)
   get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
   get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
   include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index a919b91..e171ddd 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -3,7 +3,7 @@
 
 if(NOT CMake_SOURCE_DIR)
   set(CMakeHelp_STANDALONE 1)
-  cmake_minimum_required(VERSION 3.13...3.30 FATAL_ERROR)
+  cmake_minimum_required(VERSION 3.13...3.31 FATAL_ERROR)
   get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
   get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
   include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)