summaryrefslogtreecommitdiffstats
path: root/.cmake.conf
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-21 10:20:17 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-10-01 14:32:36 +0200
commit657525965b86cfa135bb5a814a537443163acb14 (patch)
tree759d736837ebde6a87c9a0d97649428c5e76044a /.cmake.conf
parentccf504abeefe625b65750daa091ec8daf606b990 (diff)
CMake: Warn if cmake_minimum_required has an unsupported low version
Qt6Config.cmake calls cmake_minimum_required to ensure a recent enough CMake version is used in projects. That call does not set policies in the calling subdirectory scope, because find_package introduces a new policy scope. If a project using Qt has a 'cmake_minimum_required(VERSION 3.1)' call and is configured with a recent CMake, many policies will still be set to OLD. One such policy is CMP0071 (Run AUTOMOC on GENERATED files). The policy value is queried at generation time rather than at target definition time, which means we can't influence the policy value (e.g. inside the implementation of qt_add_executable for example) The inability to influence the policy value for targets created by our own CMake functions is unfortunate and can lead to issues (in the case of the above policy to compilation / linker issues). Record the version of the last cmake_minimum_required call before the Qt packages are found and error out if the version is lower than the minimum supported one. A project can reduce the error into a warning by specifying a -DQT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT_IN_CMAKE_MIN_REQUIRED=3.xyz option when configuring the project. If the option is used and build issues arise, no official support is given. All the CMake example projects shipped with Qt specify a minimum version of 3.16 already (which is the minimum for shared Qt builds), so it shouldn't be an issue to require that in other user projects as well. Implementation wise, we follow the existing pattern to record what the minimum and computed versions for static and shared Qt builds are at qtbase configure time. These are then checked before the Qt6 or QtFoo packages are find_package'd. Amends 6518bcc167d47e1c27d082c21551b9a838b04e5d Pick-to: 6.2 Task-number: QTBUG-95018 Task-number: QTBUG-95832 Change-Id: I1a1d06d82f566c92192a699045127943604c8353 Reviewed-by: Craig Scott <craig.scott@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to '.cmake.conf')
-rw-r--r--.cmake.conf12
1 files changed, 10 insertions, 2 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 7e3a04a0df..5d7ef22e8e 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,16 +1,24 @@
set(QT_REPO_MODULE_VERSION "6.3.0")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
-# Minimum requirement for building Qt
+# Minimum required CMake version 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")
-# Minimum requirement for consuming Qt in a user project.
+# Minimum required CMake version for using 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")
+# Minimum CMake version that needs to appear in the cmake_minimum_required() call of a Qt user
+# project, so that all policies defined up to the specified CMake version are using NEW behavior.
+# With a value of 3.16, all policies CMP0000-CMP0097 will use NEW behavior.
+#
+# For now, both shared and static Qt builds share the same minimum.
+set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED_IN_CMAKE_MIN_REQUIRED "3.16")
+set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC_IN_CMAKE_MIN_REQUIRED "3.16")
+
# 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
# modules have the same policy settings as qtbase by default. They can be