summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-03-04 11:50:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-05 07:57:25 +0000
commiteb501f06d7813fd9c2d1df43b099c8f20088e8eb (patch)
treecef847b578f4dfbc21872ac7c9299f1326b80357
parent545f262385fa1fdf84fa42e23e9ac87338a77778 (diff)
CMake: Fail gracefully when using an unsupported CMake version
Previously if qtwebengine was configured with a CMake version lower than 3.19, CMake would exit with a fatal error saying the version is too low. Now the CMake version check is delayed to the configure summary which changes the hard error into a build time warning instead, just like with all the other repo requirements. An additional cmake_minimum_required call is used to require all 3.19 behaviors (upgraded policies) once configure establishes that the CMake version is new enough. Change-Id: I03a20ae62ce2dcee23e5615241c6c97a86df4d2f Reviewed-by: Michal Klocek <michal.klocek@qt.io> (cherry picked from commit 0332065357a5f65bb43d113f99a7138d0bc65261) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--.cmake.conf1
-rw-r--r--CMakeLists.txt5
-rw-r--r--configure.cmake10
-rw-r--r--src/CMakeLists.txt4
4 files changed, 18 insertions, 2 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 75aec0703..d51f66d4b 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1,2 +1,3 @@
set(QT_REPO_MODULE_VERSION "6.3.0")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
+set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_WEBENGINE "3.19")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b0a0c7ffb..649c8c885 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,7 @@
-cmake_minimum_required(VERSION 3.19)
+# Require the Qt (not WebEngine) minimum supported CMake version.
+# Another WebEngine-specific version check will be done in configure.cmake
+# and reported in the configure summary.
+cmake_minimum_required(VERSION 3.16)
include(.cmake.conf)
include(ExternalProject)
diff --git a/configure.cmake b/configure.cmake
index 40059662b..3baf5d4ad 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -366,6 +366,16 @@ else()
set(WIN_ARM_64 OFF)
endif()
+add_check_for_support(
+ MODULES QtWebEngine QtPdf
+ CONDITION
+ CMAKE_VERSION
+ VERSION_GREATER_EQUAL
+ ${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_WEBENGINE}
+ MESSAGE
+ "Build requires CMake ${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_WEBENGINE} or higher."
+)
+
assertTargets(
MODULES QtWebEngine QtPdf
TARGETS Gui Quick Qml
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 227e1186e..31123d06c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,3 @@
-cmake_minimum_required(VERSION 3.19)
##
# MAIN CONFIGURE
##
@@ -52,6 +51,9 @@ if(NOT QT_FEATURE_qtwebengine_build AND NOT QT_FEATURE_qtpdf_build)
return()
endif()
+# Upgrade CMake policies to the minimum supported version.
+cmake_minimum_required(VERSION ${QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_WEBENGINE})
+
##
# MODULES
##