summaryrefslogtreecommitdiffstats
path: root/cmake/QtTargetHelpers.cmake
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-03-11 12:41:36 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2022-03-11 20:32:08 +0100
commit57c1e8d5339979cf124f28c58adc87c3d91a7fc2 (patch)
tree1f65bedf276491fc90fbf793c1e42fec124b2973 /cmake/QtTargetHelpers.cmake
parentd743fd0d0a0387d4435dd8d35f57023492a6d54b (diff)
build system: support module local definitions
This introduces a new helper function, qt_internal_add_repo_local_defines and makes use of it in qt_internal_add_{module,test,executable,benchmark,plugin}. That function checks whether QT_EXTRA_INTERNAL_TARGET_DEFINES is set. If it is, the defines listed in there will be aded to all targets passed to the functions mentioned above. The intended usage is that QT_EXTRA_INTERNAL_TARGET_DEFINES gets set in the repository local .cmake.conf. This allows e.g. opting in to source incompatible changes in leaf modules (as long as those are guarded by some define). Pick-to: 6.2 6.3 Fixes: QTBUG-101640 Change-Id: I06c3693ee69f46e95a48de724621f0c97e7cc3a8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtTargetHelpers.cmake')
-rw-r--r--cmake/QtTargetHelpers.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake
index d26e84ce16..9640287ea9 100644
--- a/cmake/QtTargetHelpers.cmake
+++ b/cmake/QtTargetHelpers.cmake
@@ -874,3 +874,19 @@ function(qt_internal_undefine_global_definition target)
set_target_properties(${target} PROPERTIES "${undef_property_name}" TRUE)
endforeach()
endfunction()
+
+# This function adds any defines which are local to the current repository (e.g. qtbase,
+# qtmultimedia). Those can be defined in the corresponding .cmake.conf file via
+# QT_EXTRA_INTERNAL_TARGET_DEFINES. QT_EXTRA_INTERNAL_TARGET_DEFINES accepts a list of definitions.
+# The definitions are passed to target_compile_definitions, which means that values can be provided
+# via the FOO=Bar syntax
+# This does nothing for interface targets
+function(qt_internal_add_repo_local_defines target)
+ get_target_property(type "${target}" TYPE)
+ if (${type} STREQUAL "INTERFACE_LIBRARY")
+ return()
+ endif()
+ if(DEFINED QT_EXTRA_INTERNAL_TARGET_DEFINES)
+ target_compile_definitions("${target}" PRIVATE ${QT_EXTRA_INTERNAL_TARGET_DEFINES})
+ endif()
+endfunction()