浏览代码

FetchContent: Update policy settings to CMake 4.1

The warning for policy CMP0174 can be triggered if a project mistakenly
specifies CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND,
or TEST_COMMAND as keywords to FetchContent_Declare() and it passes
an empty string after the keyword. It shouldn't be specifying any of those
keywords, but doing so has always worked because FetchContent_Declare()
explicitly discards them. However, when a project specifies them, they get
used internally in contexts where the policy settings are those of the
FetchContent module itself. Those settings haven't been updated past
CMake 3.29, and CMP0174 came in with CMake 3.31.

Update the policy settings for FetchContent to avoid triggering the CMP0174
warning when a project erroneously specifies the prohibited keywords.

Fixes: #27157
Craig Scott 2 月之前
父节点
当前提交
20c751bdcb
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      Modules/ExternalProject/shared_internal_commands.cmake
  2. 1 1
      Modules/FetchContent.cmake

+ 1 - 1
Modules/ExternalProject/shared_internal_commands.cmake

@@ -1,4 +1,4 @@
-cmake_policy(VERSION 3.25)
+cmake_policy(VERSION 4.1)
 
 # Determine the remote URL of the project containing the working_directory.
 # This will leave output_variable unset if the URL can't be determined.

+ 1 - 1
Modules/FetchContent.cmake

@@ -1138,7 +1138,7 @@ current working directory.
 # FetchContent_MakeAvailable() implementation details are excluded for
 # backward compatibility reasons (see just after the endblock()).
 block(SCOPE_FOR POLICIES)
-cmake_policy(VERSION 3.29)
+cmake_policy(VERSION 4.1)
 
 include(${CMAKE_CURRENT_LIST_DIR}/ExternalProject/shared_internal_commands.cmake)