From be9a94cb5ed2d62998f1ec35ce9e726c57eaca8b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 26 May 2025 16:04:44 +0200 Subject: [PATCH] CMake: Stop spamming CMP0156 debug messages We set the CMP0156 policy to NEW for Apple platforms for each created Qt target, but the debug message is generic, so we should only show it once. Amends c20d7bcb86361d0c9f8af3807dcad9db1a3a5ca0 Pick-to: 6.8 Task-number: QTBUG-135978 Change-Id: I332bd357999647df1d5f715d154fb568911889b1 Reviewed-by: Joerg Bornemann (cherry picked from commit 674a6dc5f66fce1cbe77a593e1fc942290d3f9b1) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtPublicCMakeVersionHelpers.cmake | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/QtPublicCMakeVersionHelpers.cmake b/cmake/QtPublicCMakeVersionHelpers.cmake index 316a69af677..17ab9b450fe 100644 --- a/cmake/QtPublicCMakeVersionHelpers.cmake +++ b/cmake/QtPublicCMakeVersionHelpers.cmake @@ -120,8 +120,13 @@ function(__qt_internal_set_cmp0156) # Honor this variable if it's set and TRUE. It was previously introduced to allow working around # the forced OLD value. if(QT_FORCE_CMP0156_TO_NEW) + get_cmake_property(debug_message_shown _qt_internal_cmp0156_debug_message_shown) + if(NOT debug_message_shown) + message(DEBUG "Force setting the CMP0156 policy to user provided value: NEW") + set_property(GLOBAL PROPERTY _qt_internal_cmp0156_debug_message_shown TRUE) + endif() + cmake_policy(SET CMP0156 "NEW") - message(DEBUG "Force setting the CMP0156 policy to user provided value: NEW") return() endif() @@ -163,8 +168,13 @@ function(__qt_internal_set_cmp0156) # Force set the default policy value for the given platform, even if the policy value is # the same or empty. That's because in the calling function scope, the value can be empty # due to the cmake_minimum_required call in Qt6Config.cmake resetting the policy value. - message(DEBUG "Force setting the CMP0156 policy to '${default_policy_value}' " - "for ${platform_string} platforms.") + get_cmake_property(debug_message_shown _qt_internal_cmp0156_debug_message_shown) + if(NOT debug_message_shown) + message(DEBUG "Force setting the CMP0156 policy to '${default_policy_value}' " + "for ${platform_string} platforms.") + set_property(GLOBAL PROPERTY _qt_internal_cmp0156_debug_message_shown TRUE) + endif() + cmake_policy(SET CMP0156 "${default_policy_value}") # If the policy is explicitly set to a value other than the default, issue a warning.