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 <alexey.edelev@qt.io>
(cherry picked from commit a13bfec63df2cf206e354ab56fc017a1f0eb8f6d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2023-12-04 16:41:38 +01:00 committed by Qt Cherry-pick Bot
parent 5653829bf8
commit cdc8811492
2 changed files with 10 additions and 4 deletions

View File

@ -844,9 +844,9 @@ function(_qt_internal_get_cached_xcode_version out_var)
set(${out_var} "${xcode_version}" PARENT_SCOPE) set(${out_var} "${xcode_version}" PARENT_SCOPE)
endfunction() 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. # with CMake.
# The warnings ARE shown for qmake user projects. # The warnings ARE shown for qmake user projects.
# #
@ -891,11 +891,14 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
endif() endif()
# The default differs in different branches. # The default differs in different branches.
set(failed_check_should_error FALSE) set(failed_check_should_error TRUE)
if(failed_check_should_error) if(failed_check_should_error)
# Allow downgrading the error into a warning. # 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(message_type WARNING)
set(extra_message " Due to QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK being ON " 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.") "the build will continue, but it will likely fail. Use at your own risk.")

View File

@ -142,6 +142,9 @@ function(_qt_internal_get_cmake_test_configure_options out_var)
list(APPEND option_list "-DQT_BUILD_DIR=${QT_BUILD_DIR}") list(APPEND option_list "-DQT_BUILD_DIR=${QT_BUILD_DIR}")
endif() 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) if(APPLE AND CMAKE_OSX_ARCHITECTURES)
list(LENGTH CMAKE_OSX_ARCHITECTURES osx_arch_count) list(LENGTH CMAKE_OSX_ARCHITECTURES osx_arch_count)