summaryrefslogtreecommitdiffstats
path: root/cmake/QtTargetHelpers.cmake
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2022-11-03 16:38:51 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2022-12-08 23:24:22 +0100
commit2e514f85111ec1ecd8b6f6a5c48edcf43647a006 (patch)
tree73d172146ca2d3b230e6a1c4fc5b4eab52a665c1 /cmake/QtTargetHelpers.cmake
parent050b849c9664ba15cbe4a6ec176fec217f276094 (diff)
Add CONDITION_INDEPENDENT_SOURCES argument to qt_internal_extend_target
The argument allows to ignore the condition for source files if they are used in the Qt code without corresponding guards. The header files of this kind usually have internal guards, that suppress the error at the location where they are used, so AUTOGEN is skipped for these header files to suppress the warnings from CMake. If file belongs to a module, it will display AUTHOR_WARNING which should urge Qt maintainers to guard the use of the source file properly. Task-number: QTBUG-103196 Change-Id: I7b4c12031a5d19ff15868d4782c0d396ef7aed8c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'cmake/QtTargetHelpers.cmake')
-rw-r--r--cmake/QtTargetHelpers.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake
index 4b0f176b36..cf101c1f85 100644
--- a/cmake/QtTargetHelpers.cmake
+++ b/cmake/QtTargetHelpers.cmake
@@ -9,6 +9,9 @@
# Multi-value Arguments:
# CONDITION
# The condition under which the target will be extended.
+# CONDITION_INDEPENDENT_SOURCES
+# Source files that should be added to the target unconditionally. Note that if target is Qt
+# module, these files will raise a warning at configure time if the condition is not met.
# COMPILE_FLAGS
# Custom compilation flags.
# NO_PCH_SOURCES
@@ -37,6 +40,7 @@ function(qt_internal_extend_target target)
${__default_private_args}
${__default_private_module_args}
CONDITION
+ CONDITION_INDEPENDENT_SOURCES
COMPILE_FLAGS
NO_PCH_SOURCES
)
@@ -211,6 +215,17 @@ function(qt_internal_extend_target target)
message("qt_extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped")
endif()
endif()
+
+ if(arg_CONDITION_INDEPENDENT_SOURCES)
+ set_source_files_properties(${arg_CONDITION_INDEPENDENT_SOURCES} PROPERTIES
+ _qt_extend_target_condition "${arg_CONDITION}"
+ SKIP_AUTOGEN TRUE
+ )
+
+ qt_internal_get_target_sources_property(sources_property)
+ set_property(TARGET ${target} APPEND PROPERTY
+ ${sources_property} "${arg_CONDITION_INDEPENDENT_SOURCES}")
+ endif()
endfunction()
function(qt_is_imported_target target out_var)