CMake: Refactor sdk / xcode check to support both warnings and errors

The minimum sdk / xcode version is a requirement, so if the minimum is
not met, we should generally error out.
Changing the behavior in the already released 6.6.x series is not nice
though.

Refactor the code to support both a warning-first and error-first
approach. Keep the warning-first behavior as-is in this change and pick
it to all relevant branches.
A follow up change will switch the default to the error-first approach
for as-of-yet unreleased Qt branches.

To support both approaches, there are now two variables to flip the
warnings into errors and vice-versa depending on which is the default
for a particular branch:
- QT_FORCE_FATAL_APPLE_SDK_AND_XCODE_CHECK
- QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK

The maximum SDK version check remains a warning, because building
against the newer SDK might still work, even if it isn't yet marked as
supported.

Amends a29bff3d80219f54d0837b0e6e0577192011dea1

Pick-to: 6.6
Task-number: QTBUG-119490
Change-Id: I92dedd69efc266dfc1c8cf15c93887be74fc99d8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2023-12-04 13:23:39 +01:00
parent 11c522495d
commit 248f8bff16

View File

@ -789,19 +789,12 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
return()
endif()
# Only show the warnings once in a top-level build.
get_property(warnings_shown GLOBAL PROPERTY _qt_internal_apple_sdk_and_xcode_warnings_shown)
if(warnings_shown)
# Only run the check once in a top-level build.
get_property(check_done GLOBAL PROPERTY _qt_internal_apple_sdk_and_xcode_check_done)
if(check_done)
return()
endif()
set_property(GLOBAL PROPERTY _qt_internal_apple_sdk_and_xcode_warnings_shown "TRUE")
# Allow upgrading the warning into an error.
if(QT_FORCE_FATAL_APPLE_SDK_AND_XCODE_CHECK)
set(message_type FATAL_ERROR)
else()
set(message_type WARNING)
endif()
set_property(GLOBAL PROPERTY _qt_internal_apple_sdk_and_xcode_check_done "TRUE")
if(IOS)
set(min_sdk_version "${QT_SUPPORTED_MIN_IOS_SDK_VERSION}")
@ -816,10 +809,39 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
_qt_internal_get_cached_apple_sdk_version(sdk_version)
_qt_internal_get_cached_xcode_version(xcode_version)
# The default differs in different branches.
set(failed_check_should_error FALSE)
if(failed_check_should_error)
# Allow downgrading the error into a warning.
if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK)
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.")
else()
set(message_type FATAL_ERROR)
set(extra_message " You can turn this error into a warning by configuring with "
"-DQT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK=ON, but the build will likely fail. "
"Use at your own risk.")
endif()
else()
# Allow upgrading the warning into an error.
if(QT_FORCE_FATAL_APPLE_SDK_AND_XCODE_CHECK)
set(message_type FATAL_ERROR)
set(extra_message " Erroring out due to QT_FORCE_FATAL_APPLE_SDK_AND_XCODE_CHECK "
"being ON.")
else()
set(message_type WARNING)
set(extra_message " You can turn this warning into an error by configuring with "
"-DQT_FORCE_FATAL_APPLE_SDK_AND_XCODE_CHECK=ON. ")
endif()
endif()
if(sdk_version VERSION_LESS min_sdk_version AND NOT QT_NO_APPLE_SDK_MIN_VERSION_CHECK)
message(${message_type}
"Qt requires at least version ${min_sdk_version} of the platform SDK, "
"you're building against version ${sdk_version}. Please upgrade."
${extra_message}
)
endif()
@ -827,6 +849,7 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
message(${message_type}
"Qt requires at least version ${min_xcode_version} of Xcode, "
"you're building against version ${xcode_version}. Please upgrade."
${extra_message}
)
endif()
@ -834,8 +857,10 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
return()
endif()
# Upper bound checks should always be warnings, because the build might still work even
# if untested.
if(sdk_version VERSION_GREATER_EQUAL max_sdk_version)
message(${message_type}
message(WARNING
"Qt has only been tested with version ${max_sdk_version} "
"of the platform SDK, you're using ${sdk_version}. "
"This is an unsupported configuration. You may experience build issues, "