summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-12-06 21:07:38 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-12-10 10:43:38 +0000
commitb9c80ecc08d98052e4757a916a8a55701be63497 (patch)
tree56f87dd073beca90db95da6f978b979023fe1a78 /cmake
parent8aae821b5aa2bd0ac919683dcb3cb62913ca9063 (diff)
CMake: Add qt 'policy' support
This mimics CMake's policy support. The policy state is stored in an internal __QT_INTERNAL_POLICY_<policy> variable; by using normal variables, we gain support for stacking for free. Policies can be explicitly en- or disable via qt6_policy; that command also has a GET mode to retrieve them again. Furthermore, one can now pass min and max version to qt6_standard_project_setup, to opt in to a certain set of defaults introduced in a given Qt version. We add support for policies in QtModuleHelpers, so that we can check for known policies while building Qt itself. No actual policies exist yet; but a follow up commit will introduce one for qt_add_qml_module. Change-Id: I57a0404c9193926dd499f94cc5f73e359355c0b3 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtModuleHelpers.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake
index 9a9e3bec1d..8a8912bfb4 100644
--- a/cmake/QtModuleHelpers.cmake
+++ b/cmake/QtModuleHelpers.cmake
@@ -39,6 +39,7 @@ macro(qt_internal_get_internal_add_module_keywords option_args single_args multi
EXTRA_CMAKE_INCLUDES
NO_PCH_SOURCES
EXTERNAL_HEADERS
+ POLICIES
${__default_private_args}
${__default_public_args}
${__default_private_module_args}
@@ -674,6 +675,21 @@ set(QT_LIBINFIX \"${QT_LIBINFIX}\")")
set(extra_cmake_code "")
+ if(arg_POLICIES)
+ set(policies "")
+ foreach(policy IN LISTS arg_POLICIES)
+ list(APPEND policies "set(QT_KNOWN_POLICY_${policy} TRUE)")
+
+ # When building Qt, tests and examples might expect a policy to be known, but they
+ # won't be known depending on which scope or when a find_package(Module) with the
+ # respective policy is called. Check the global list of known policies to accommodate
+ # that.
+ set_property(GLOBAL APPEND PROPERTY _qt_global_known_policies "${policy}")
+ endforeach()
+ list(JOIN policies "\n" policies_str)
+ string(APPEND extra_cmake_code "${policies_str}\n")
+ endif()
+
# Generate metatypes
if(${arg_GENERATE_METATYPES})
# No mention of NO_GENERATE_METATYPES. You should not use it.