summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/QtModuleHelpers.cmake21
-rw-r--r--cmake/QtTargetHelpers.cmake15
2 files changed, 36 insertions, 0 deletions
diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake
index 563482c378..59340222bb 100644
--- a/cmake/QtModuleHelpers.cmake
+++ b/cmake/QtModuleHelpers.cmake
@@ -1125,11 +1125,20 @@ function(qt_internal_collect_module_headers out_var target)
get_target_property(private_filter ${target} _qt_module_private_headers_filter_regex)
get_target_property(qpa_filter ${target} _qt_module_qpa_headers_filter_regex)
+ set(condition_independent_headers_warning "")
foreach(file_path IN LISTS sources)
get_filename_component(file_name "${file_path}" NAME)
if(NOT file_name MATCHES ".+\\.h$")
continue()
endif()
+ get_source_file_property(condition ${file_path} _qt_extend_target_condition)
+ if(NOT condition STREQUAL "" AND NOT condition STREQUAL "NOTFOUND")
+ list(JOIN condition " " condition_string)
+ string(APPEND condition_independent_headers_warning
+ "\nFile:\n ${file_path}"
+ "\nCondition:\n ${condition_string}")
+ endif()
+
get_source_file_property(is_generated "${file_path}" GENERATED)
get_filename_component(file_path "${file_path}" ABSOLUTE)
get_filename_component(file_path "${file_path}" REALPATH)
@@ -1146,6 +1155,18 @@ function(qt_internal_collect_module_headers out_var target)
endif()
endforeach()
+ if(NOT condition_independent_headers_warning STREQUAL "" AND QT_FEATURE_developer_build)
+ message(AUTHOR_WARNING "Condition is ignored when adding the following header file(s) to"
+ " the ${target} module:"
+ "${condition_independent_headers_warning}"
+ "\nThe usage of the file(s) is not properly isolated in this or other modules according"
+ " to the condition. This warning is for the Qt maintainers. Please make sure that file"
+ " include(s) are guarded with the appropriate macros in the Qt code. If files should be"
+ " added to the module unconditionally, please move them to the common SOURCES section"
+ " in the qt_internal_add_module call.")
+ endif()
+
+
set(header_types public private qpa)
set(has_header_types_properties "")
foreach(header_type IN LISTS header_types)
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)