path: root/cmake/
diff options
authorAlexandru Croitor <>2021-07-22 16:23:51 +0200
committerAlexandru Croitor <>2021-08-04 16:03:08 +0200
commit6518bcc167d47e1c27d082c21551b9a838b04e5d (patch)
tree4faa5bcfb7f33fd0980b8dbbdb2e96a2d5802cb5 /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 <> Reviewed-by: Joerg Bornemann <>
Diffstat (limited to 'cmake/')
1 files changed, 4 insertions, 0 deletions
diff --git a/cmake/ b/cmake/
index 92e47a04a0..7f5698a34c 100644
--- a/cmake/
+++ b/cmake/
@@ -2,6 +2,10 @@
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")