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 <joerg.bornemann@qt.io>
(cherry picked from commit 674a6dc5f66fce1cbe77a593e1fc942290d3f9b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2025-05-26 16:04:44 +02:00 committed by Qt Cherry-pick Bot
parent af623abc58
commit be9a94cb5e

View File

@ -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.