From 20c751bdcb86a617f11eedacb763bd25641a3e8c Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Fri, 5 Sep 2025 15:17:03 +1000 Subject: [PATCH] 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 --- Modules/ExternalProject/shared_internal_commands.cmake | 2 +- Modules/FetchContent.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/ExternalProject/shared_internal_commands.cmake b/Modules/ExternalProject/shared_internal_commands.cmake index df1290ee70..070328b67e 100644 --- a/Modules/ExternalProject/shared_internal_commands.cmake +++ b/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. diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index fb9c2e5a21..9daa50e316 100644 --- a/Modules/FetchContent.cmake +++ b/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)