CMake: Decouple applied cmake policies from CMake version set
We might want to raise the minimum CMake version for building or using Qt, while keeping the minimum and maximum CMake policy NEW values lower than the CMake min/max versions, because bumping the policy values requires more testing. Previously we always used the min cmake version as the lower range for the policies. Split QT_MIN_NEW_POLICY_CMAKE_VERSION and QT_MAX_NEW_POLICY_CMAKE_VERSION into per-type variables: - QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_SHARED - QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_STATIC - QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_APPLE - QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_SHARED - QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_STATIC - QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_APPLE And change qt_internal_upgrade_cmake_policies to use the min new policy as the lower range, instead of the min cmake version. Pick-to: 6.8 Task-number: QTBUG-131169 Change-Id: Ib39a377edf20e497dc8f7d742b48d102a66c6a95 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
a60d42d873
commit
572a313bb9
25
.cmake.conf
25
.cmake.conf
@ -24,17 +24,28 @@ set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED "3.16")
|
||||
set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC "3.21")
|
||||
set(QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_APPLE "3.21")
|
||||
|
||||
# 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
|
||||
# overridden by individual Qt modules in their own .cmake.conf files if needed.
|
||||
# Policy settings for commands defined by qtbase.
|
||||
# These will also be injected into the top level policy scope of each Qt
|
||||
# repo when building Qt so that repos have the same policy settings as
|
||||
# qtbase by default. They can be overridden by individual Qt repos
|
||||
# in their own .cmake.conf files if needed.
|
||||
# This affects both internal and public api commands, because the policies are
|
||||
# written into the generated QtFooConfig.cmake.in files.
|
||||
#
|
||||
# NOTE: These two values are also hard-coded in QtBuildInternalsConfig.cmake
|
||||
# NOTE: Some of these values are also hard-coded in
|
||||
# QtBuildInternalsConfig.cmake at the top of the file
|
||||
# because that file is used in-place by a superbuild, so there is no
|
||||
# opportunity for substituting the values from here. Keep both locations
|
||||
# in sync.
|
||||
set(QT_MIN_NEW_POLICY_CMAKE_VERSION "3.16")
|
||||
set(QT_MAX_NEW_POLICY_CMAKE_VERSION "3.21")
|
||||
# TODO: Figure out how to handle the platform values there
|
||||
# given we now set them conditionally
|
||||
set(QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_SHARED "3.16")
|
||||
set(QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_STATIC "3.16")
|
||||
set(QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_APPLE "3.16")
|
||||
|
||||
set(QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_SHARED "3.21")
|
||||
set(QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_STATIC "3.21")
|
||||
set(QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_APPLE "3.21")
|
||||
|
||||
# Apple version constraints. Used when building Qt and documentation
|
||||
set(QT_SUPPORTED_MIN_MACOS_SDK_VERSION "14")
|
||||
|
@ -86,9 +86,26 @@ endfunction()
|
||||
# is only used for policy settings. The currently running CMake must not be
|
||||
# older than this version though (doing so will result in an error).
|
||||
function(qt_internal_get_min_new_policy_cmake_version out_var)
|
||||
# QT_MIN_NEW_POLICY_CMAKE_VERSION is set either in .cmake.conf or in
|
||||
# QtBuildInternalsExtras.cmake when building a child repo.
|
||||
set(lower_version "${QT_MIN_NEW_POLICY_CMAKE_VERSION}")
|
||||
if(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "BUILD_SHARED_LIBS is needed to decide the oldest CMake version "
|
||||
"for which NEW policies should be enabled. "
|
||||
"It should have been set by this point.")
|
||||
endif()
|
||||
|
||||
# First check if a value is already set in QtBuildInternalsExtras.cmake, which means we're
|
||||
# building a repo other than qtbase and the lower version was already recorded.
|
||||
if(QT_MIN_NEW_POLICY_CMAKE_VERSION)
|
||||
set(lower_version "${QT_MIN_NEW_POLICY_CMAKE_VERSION}")
|
||||
|
||||
# We're building qtbase so the values come from .cmake.conf.
|
||||
elseif(APPLE)
|
||||
set(lower_version "${QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_APPLE}")
|
||||
elseif(BUILD_SHARED_LIBS)
|
||||
set(lower_version "${QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_SHARED}")
|
||||
else()
|
||||
set(lower_version "${QT_MIN_NEW_POLICY_CMAKE_VERSION_QT_STATIC}")
|
||||
endif()
|
||||
|
||||
set(${out_var} "${lower_version}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
@ -96,13 +113,31 @@ endfunction()
|
||||
# This cannot be less than the minimum CMake policy version or we will end up
|
||||
# specifying a version range with the max less than the min.
|
||||
function(qt_internal_get_max_new_policy_cmake_version out_var)
|
||||
# QT_MAX_NEW_POLICY_CMAKE_VERSION is set either in .cmake.conf or in
|
||||
# QtBuildInternalsExtras.cmake when building a child repo.
|
||||
set(upper_version "${QT_MAX_NEW_POLICY_CMAKE_VERSION}")
|
||||
if(NOT DEFINED BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "BUILD_SHARED_LIBS is needed to decide the latest CMake version "
|
||||
"for which NEW policies should be enabled. "
|
||||
"It should have been set by this point.")
|
||||
endif()
|
||||
|
||||
# First check if a value is already set in QtBuildInternalsExtras.cmake, which means we're
|
||||
# building a repo other than qtbase and the lower version was already recorded.
|
||||
if(QT_MAX_NEW_POLICY_CMAKE_VERSION)
|
||||
set(upper_version "${QT_MAX_NEW_POLICY_CMAKE_VERSION}")
|
||||
|
||||
# We're building qtbase so the values come from .cmake.conf.
|
||||
elseif(APPLE)
|
||||
set(upper_version "${QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_APPLE}")
|
||||
elseif(BUILD_SHARED_LIBS)
|
||||
set(upper_version "${QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_SHARED}")
|
||||
else()
|
||||
set(upper_version "${QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_STATIC}")
|
||||
endif()
|
||||
|
||||
qt_internal_get_min_new_policy_cmake_version(lower_version)
|
||||
if(upper_version VERSION_LESS lower_version)
|
||||
set(upper_version ${lower_version})
|
||||
endif()
|
||||
|
||||
set(${out_var} "${upper_version}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
@ -230,7 +265,7 @@ endfunction()
|
||||
# but not to any that are already defined. Ordinary CMake code not inside a
|
||||
# function or macro will be affected by these policy settings too.
|
||||
function(qt_internal_upgrade_cmake_policies)
|
||||
qt_internal_get_computed_min_cmake_version_for_building_qt(lower_version)
|
||||
qt_internal_get_min_new_policy_cmake_version(lower_version)
|
||||
qt_internal_get_max_new_policy_cmake_version(upper_version)
|
||||
cmake_minimum_required(VERSION ${lower_version}...${upper_version})
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user