diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-12-04 13:23:39 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-12-05 16:28:22 +0000 |
commit | 88f25422aa604e238e04b3a260e9b69702306065 (patch) | |
tree | 1abf9f3e0077a3f1b41be05e18b23a69cbd01e0b /cmake | |
parent | ccca14cdd88ad3b16f25debea120bc87c6a854a7 (diff) |
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
Task-number: QTBUG-119490
Change-Id: I92dedd69efc266dfc1c8cf15c93887be74fc99d8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 248f8bff16e7b49f9ac946b78a0577051480be58)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtPublicAppleHelpers.cmake | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/cmake/QtPublicAppleHelpers.cmake b/cmake/QtPublicAppleHelpers.cmake index aaab58f31e..2d807ef830 100644 --- a/cmake/QtPublicAppleHelpers.cmake +++ b/cmake/QtPublicAppleHelpers.cmake @@ -792,19 +792,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}") @@ -819,10 +812,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() @@ -830,6 +852,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() @@ -837,8 +860,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, " |