summaryrefslogtreecommitdiffstats
path: root/cmake/QtPostProcessHelpers.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-07-22 16:23:51 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-08-04 16:03:08 +0200
commit6518bcc167d47e1c27d082c21551b9a838b04e5d (patch)
tree4faa5bcfb7f33fd0980b8dbbdb2e96a2d5802cb5 /cmake/QtPostProcessHelpers.cmake
parent9aa0d99e66b8be2be75d4f3b7fce2b94db9a1e32 (diff)
CMake: Enforce minimum CMake version in user projects
This change introduces new behavior to error out when configuring user projects if the CMake version used is too old for Qt to work with. The main motivator is the requirement of new CMake features to ensure object libraries are placed in the proper place on the link line in static builds. The minimum CMake version is computed based on whether Qt was configured as shared or static libraries. At the moment the required versions for building and using Qt are the same. The minimum versions are defined in qtbase/.cmake.conf in the following variables QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_STATIC QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC Qt Packagers can disable the version check when configuring Qt by setting QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT and QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT. In this case it is the packagers responsibility to ensure such a Qt works correctly with the specified CMake version. User projects can also set QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT to disable the version check. Then it's the project's developer responsibility to ensure such a Qt works correctly. No official support is provided for these cases. Implementation notes. The versions required to build Qt are stored in QtBuildInternalsExtra.cmake whereas the versions required to use Qt are stored in a new QtConfigExtras.cmake. Also the policy range variables stored in QtBuildInternalsExtra.cmake are now regular variables instead of cache variables, to properly allow overrides per-repository. Some renaming of functions and variables was done for a bit more clarity and easier grep-ability. Pick-to: 6.2 Task-number: QTBUG-95018 Change-Id: I4279f2e10b6d3977319237ba21e2f4ed676aa48b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtPostProcessHelpers.cmake')
-rw-r--r--cmake/QtPostProcessHelpers.cmake22
1 files changed, 10 insertions, 12 deletions
diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake
index 248989c81c..f8f42d273e 100644
--- a/cmake/QtPostProcessHelpers.cmake
+++ b/cmake/QtPostProcessHelpers.cmake
@@ -556,18 +556,16 @@ endif()\n")
endif()
# Save minimum and policy-related CMake versions to ensure the same minimum is
- # checked for when building other child repos (qtsvg, etc) and the policy settings
- # will be consistent unless the child repos explicitly override them.
- qt_internal_get_qt_supported_minimum_cmake_version(min_supported_version)
- qt_internal_get_computed_minimum_cmake_version(computed_min_version)
- qt_internal_get_min_new_policy_cmake_version(lower_policy_version)
- qt_internal_get_max_new_policy_cmake_version(upper_policy_version)
- string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
- "set(QT_MIN_SUPPORTED_CMAKE_VERSION \"${min_supported_version}\" CACHE STRING \"Minimum supported CMake version required to build Qt\")\n"
- "set(QT_COMPUTED_MIN_CMAKE_VERSION \"${computed_min_version}\" CACHE STRING \"Computed minimum CMake version required to build Qt\")\n"
- "set(QT_MIN_NEW_POLICY_CMAKE_VERSION \"${lower_policy_version}\" CACHE STRING \"Oldest CMake version for which NEW policies should be enabled\")\n"
- "set(QT_MAX_NEW_POLICY_CMAKE_VERSION \"${upper_policy_version}\" CACHE STRING \"Latest CMake version for which NEW policies should be enabled\")\n"
- )
+ # checked for when building other downstream repos (qtsvg, etc) and the policy settings
+ # will be consistent unless the downstream repos explicitly override them.
+ # Policy settings can be overridden per-repo, but the minimum CMake version is global for all of
+ # Qt.
+ qt_internal_get_supported_min_cmake_version_for_building_qt(
+ supported_min_version_for_building_qt)
+ qt_internal_get_computed_min_cmake_version_for_building_qt(
+ computed_min_version_for_building_qt)
+ qt_internal_get_min_new_policy_cmake_version(min_new_policy_version)
+ qt_internal_get_max_new_policy_cmake_version(max_new_policy_version)
# Rpath related things that need to be re-used when building other repos.
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS