From 9ef864f56f1a049237f599b65684fa6d5ce06f55 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 26 Jun 2023 16:40:25 +0200 Subject: [PATCH] CMake: Require CMake 3.21 when building/using Qt on Apple platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explicitly check that at least CMake 3.21 is used when building Qt or when using Qt in a project. This only affects macOS and iOS builds. We check for 3.21 instead of 3.21.1 as described in the documentation to avoid an error like: Policy VERSION range "3.21.1...3.21" specifies a larger minimum than maximum. Until the technical limitation is addressed, if someone does end up using 3.21.1, another existing check for "unsuitable" cmake versions (as opposed to minimum required) will let them know they should use something newer. Amends 1cf3295cef321c9a587af2f2de7740c0cd3ca743. Pick-to: 6.6 Fixes: QTBUG-114869 Change-Id: I2a479baaa63cfbe23af187cf0796e1c00042692b Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø Reviewed-by: Alexey Edelev --- .cmake.conf | 2 ++ cmake/QtCMakeVersionHelpers.cmake | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.cmake.conf b/.cmake.conf index 1a97dd237a..9e1d227e1c 100644 --- a/.cmake.conf +++ b/.cmake.conf @@ -16,12 +16,14 @@ set(QT_COPYRIGHT "Copyright (C) ${QT_COPYRIGHT_YEAR} The Qt Company Ltd and othe # Minimum requirement for building Qt set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED "3.16") set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_STATIC "3.21") +set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_APPLE "3.21") # Minimum requirement for consuming Qt in a user project. # This might be different in the future, e.g. be lower than the requirement for # building Qt. set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED "3.16") set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC "3.21") +set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_APPLE "3.21") # Policy settings for commands defined by qtbase. These will also be injected # into the top level policy scope of each Qt module when building Qt so that diff --git a/cmake/QtCMakeVersionHelpers.cmake b/cmake/QtCMakeVersionHelpers.cmake index c17a75e29f..322e58eed1 100644 --- a/cmake/QtCMakeVersionHelpers.cmake +++ b/cmake/QtCMakeVersionHelpers.cmake @@ -14,6 +14,8 @@ function(qt_internal_get_supported_min_cmake_version_for_building_qt out_var) set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT}") # We're building qtbase so the values come from .cmake.conf. + elseif(APPLE) + set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_APPLE}") elseif(BUILD_SHARED_LIBS) set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED}") else() @@ -30,7 +32,9 @@ function(qt_internal_get_supported_min_cmake_version_for_using_qt out_var) "It should have been set by this point.") endif() - if(BUILD_SHARED_LIBS) + if(APPLE) + set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_APPLE}") + elseif(BUILD_SHARED_LIBS) set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED}") else() set(supported_version "${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC}")