summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2020-11-30 18:46:49 +1100
committerCraig Scott <craig.scott@qt.io>2020-12-07 13:22:57 +1100
commit3859f15ec9fd333089e6eb1152a76592cd5f83c0 (patch)
treeab1a3efb43ae5fac1dff489ce8832fd8e20bf021 /CMakeLists.txt
parentec02de374da3f796a2155b45779be222a90be2cd (diff)
CMake: Enable NEW policies by CMake version with a global default
When a CMake release introduces a new policy that affects most Qt modules, it may be appropriate to make each module aware of that newer CMake version and use the NEW policy without raising the minimum CMake version requirement. To reduce the churn associated with making that change across all Qt modules individually, this change allows it to be updated in a central place (qtbase), but in a way that allows a Qt module to override it in its own .cmake.conf file if required (e.g. to address the issues identified by policy warnings at a later time). The policies are modified at the start of the call to qt_build_repo_begin(). For commands defined by the qtbase module, qtbase needs to be in control of the policy settings at the point where those commands are defined. The above mechanism should not affect the policy settings for these commands, so the various *Config.cmake.in files must not specify policy ranges in a way that a Qt module's .cmake.conf file could influence. Starting with CMake 3.12, policies can be specified as a version range with the cmake_minimum_required() and cmake_policy() commands. All policies introduced in CMake versions up to the upper limit of that range will be set to NEW. The actual version of CMake being used only has to be at least the lower limit of the specified version range. This change uses cmake_minimum_required() rather than cmake_policy() due to the latter not halting further processing upon failure. See the following: https://gitlab.kitware.com/cmake/cmake/-/issues/21557 Task-number: QTBUG-88700 Pick-to: 6.0 Change-Id: I0a1f2611dd629f847a18186394f500d7f52753bc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt20
1 files changed, 11 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53daa1721a..3557cad293 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,16 @@
# special case skip regeneration
-# Get the repo version and the minimum CMake version.
-include("${CMAKE_CURRENT_SOURCE_DIR}/.cmake.conf")
-
-if(NOT QT_SUPER_BUILD)
- include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtCMakeVersionHelpers.cmake")
- qt_internal_check_for_suitable_cmake_version()
- qt_internal_get_computed_minimum_cmake_version(__qt_minimum_cmake_version)
- cmake_minimum_required(VERSION ${__qt_minimum_cmake_version})
-endif()
+# Need an explicit call at the top level. This is the absolute minimum version
+# needed to configure the project with any combination of enabled features.
+# The call to qt_build_repo_begin() will upgrade policies further.
+cmake_minimum_required(VERSION 3.16)
+
+# Get the repo version and CMake policy details
+include(.cmake.conf)
+
+# 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