From c98a4863ddb45ef2f2e7f63a2d0191d57833e510 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 4 Dec 2023 16:34:46 +0100 Subject: [PATCH] CMake: Fix Apple max sdk version check We need to warn only when using a major version that is the next one after the 'max supported version'. Add an assertion that the max sdk version specified in .cmake.conf needs to be just the major sdk version, without a minor or patch version component, otherwise the '+1' math expression will fail. Task-number: QTBUG-119490 Change-Id: Ib30abe7157c2ccbe0ad7a98e81fc241685a141a8 Reviewed-by: Alexey Edelev (cherry picked from commit a0bdd2195f24d8a7d880ba506afc16b41337218e) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtPublicAppleHelpers.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/QtPublicAppleHelpers.cmake b/cmake/QtPublicAppleHelpers.cmake index 2d807ef8306..434461c7961 100644 --- a/cmake/QtPublicAppleHelpers.cmake +++ b/cmake/QtPublicAppleHelpers.cmake @@ -812,6 +812,12 @@ 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) + if(NOT max_sdk_version MATCHES "^[0-9]+$") + message(FATAL_ERROR + "Invalid max SDK version: ${max_sdk_version} " + "It should be a major version number, without minor or patch version components.") + endif() + # The default differs in different branches. set(failed_check_should_error FALSE) @@ -860,9 +866,9 @@ 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) + # Make sure we warn only when the current version is greater than the max supported version. + math(EXPR next_after_max_sdk_version "${max_sdk_version} + 1") + if(sdk_version VERSION_GREATER_EQUAL next_after_max_sdk_version) message(WARNING "Qt has only been tested with version ${max_sdk_version} " "of the platform SDK, you're using ${sdk_version}. "