From cdc881149200bb86e56f9fb7e2f8bccbd7c8e1cf Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 4 Dec 2023 16:41:38 +0100 Subject: [PATCH] CMake: Error out when xcode / SDK version check fail in Qt 6.8+ Starting with Qt 6.8+ we should error out if the minimum sdk / Xcode version requirements are not met. An opt out is added for cmake build tests, otherwise all the tests that use private cmake api will fail to configure when run on older Xcode or SDK versions in the CI. We do this by checking for a new QT_INTERNAL_IS_CMAKE_BUILD_TEST variable. We do the check inside _qt_internal_check_apple_sdk_and_xcode_versions instead of passing a QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK variable to the test configuration, because not all cmake build tests use private api, so this way the list of projects that get the opt out is more constrained. Pick-to: 6.8 Task-number: QTBUG-119490 Change-Id: I1284616c91341848a9cf6406fbf35750707d1227 Reviewed-by: Alexey Edelev (cherry picked from commit a13bfec63df2cf206e354ab56fc017a1f0eb8f6d) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtPublicAppleHelpers.cmake | 11 +++++++---- src/corelib/Qt6CTestMacros.cmake | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/QtPublicAppleHelpers.cmake b/cmake/QtPublicAppleHelpers.cmake index 5d366a5c98c..ad7dd05e0b5 100644 --- a/cmake/QtPublicAppleHelpers.cmake +++ b/cmake/QtPublicAppleHelpers.cmake @@ -844,9 +844,9 @@ function(_qt_internal_get_cached_xcode_version out_var) set(${out_var} "${xcode_version}" PARENT_SCOPE) endfunction() -# Warn when the platform SDK or Xcode version are not supported. +# Warn or error out when the platform SDK or Xcode version are not supported. # -# The warnings are currently only shown when building Qt, not when building user projects +# The messages are currently only shown when building Qt, not when building user projects # with CMake. # The warnings ARE shown for qmake user projects. # @@ -891,11 +891,14 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions) endif() # The default differs in different branches. - set(failed_check_should_error FALSE) + set(failed_check_should_error TRUE) if(failed_check_should_error) # Allow downgrading the error into a warning. - if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK) + # + # Our cmake build tests might be executed on older not officially supported Xcode or SDK + # versions in the CI. Downgrade the error in this case as well. + if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK OR QT_INTERNAL_IS_CMAKE_BUILD_TEST) set(message_type WARNING) set(extra_message " Due to QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK being ON " "the build will continue, but it will likely fail. Use at your own risk.") diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake index 1edcb1bab5e..f6bdb3b3cc8 100644 --- a/src/corelib/Qt6CTestMacros.cmake +++ b/src/corelib/Qt6CTestMacros.cmake @@ -142,6 +142,9 @@ function(_qt_internal_get_cmake_test_configure_options out_var) list(APPEND option_list "-DQT_BUILD_DIR=${QT_BUILD_DIR}") endif() + # Pass a variable that can serve as a marker for cmake build tests in other build system code. + list(APPEND option_list "-DQT_INTERNAL_IS_CMAKE_BUILD_TEST=ON") + if(APPLE AND CMAKE_OSX_ARCHITECTURES) list(LENGTH CMAKE_OSX_ARCHITECTURES osx_arch_count)