From 9aa0d99e66b8be2be75d4f3b7fce2b94db9a1e32 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 6 Jul 2021 17:55:30 +0200 Subject: CMake: Bump min required CMake version for static Qt builds to 3.20 Building a static library Qt configuration will now require a minimum CMake version of 3.20. Qt builders and packagers can still opt out of the mentioned minimum required version by configuring Qt with QT_FORCE_MIN_CMAKE_VERSION. Such a Qt configuration is /NOT SUPPORTED/. To facilitate these changes, the minimum version check has been moved to happen after the BUILD_SHARED_LIBS option is computed by either QtAutoDetect.cmake or set by a user provided cmake toolchain file. Introduce a new QT_MIN_SUPPORTED_CMAKE_VERSION_FOR_STATIC_QT variable in .cmake.conf to mark the minimum version for a static Qt build. Pick-to: 6.2 Task-number: QTBUG-95018 Change-Id: Idc1875729f26a7c635b6bd26ac0c1be973917c13 Reviewed-by: Joerg Bornemann Reviewed-by: Alexey Edelev Reviewed-by: Craig Scott --- CMakeLists.txt | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 35ee14102e..c3dcc2f731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,6 @@ endif() unset(build_dir_absolute) unset(build_dir_realpath) -# Early check to reduce chance of warning being lost in the output -include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtCMakeVersionHelpers.cmake") -qt_internal_check_for_suitable_cmake_version() - # Run auto detection routines, but not when doing standalone tests. In that case, the detection # results are taken from either QtBuildInternals or the qt.toolchain.cmake file. Also, inhibit # auto-detection in a top-level build, because the top-level project file already includes it. @@ -39,6 +35,7 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_SUPERBUILD) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtAutoDetect.cmake) endif() +# This call will load any provided cmake toolchain file. project(QtBase VERSION "${QT_REPO_MODULE_VERSION}" DESCRIPTION "Qt Base Libraries" @@ -46,6 +43,22 @@ project(QtBase LANGUAGES CXX C ASM ) +# Should this Qt be static or dynamically linked? +option(BUILD_SHARED_LIBS "Build Qt statically or dynamically" ON) +set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + +# This variable is also set in Qt6CoreConfigExtras.cmake, but it's not loaded when building +# qtbase. Set it here so qt_add_plugin can compute the proper plugin flavor. +set(QT6_IS_SHARED_LIBS_BUILD ${BUILD_SHARED_LIBS}) + +# BUILD_SHARED_LIBS influences the minimum required CMake version. The value is set either by: +# a cache variable provided on the configure command line +# or set by QtAutoDetect.cmake depending on the platform +# or specified via a toolchain file that is loaded by the project() call +# or set by the option() call above +include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtCMakeVersionHelpers.cmake") +qt_internal_check_for_suitable_cmake_version() + if(NOT QT_BUILD_STANDALONE_TESTS) ## Add some paths to check for cmake modules: list(PREPEND CMAKE_MODULE_PATH @@ -77,14 +90,6 @@ endif() qt_build_repo_begin() if(NOT QT_BUILD_STANDALONE_TESTS) - ## Should this Qt be static or dynamically linked? - option(BUILD_SHARED_LIBS "Build Qt statically or dynamically" ON) - set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) - - # This variable is also set in Qt6CoreConfigExtras.cmake, but it's not loaded when building - # qtbase. Set it here so qt_add_plugin can compute the proper plugin flavor. - set(QT6_IS_SHARED_LIBS_BUILD ${BUILD_SHARED_LIBS}) - ## Should this Qt be built with Werror? option(WARNINGS_ARE_ERRORS "Build Qt with warnings as errors" ${FEATURE_developer_build}) -- cgit v1.2.3