summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-04-23 16:23:36 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2021-04-27 21:33:48 +0200
commita239045d59ba0c04a28c3ac16fbf9e9dfaa8f13c (patch)
treed436317fb5f702f0646c9ba2753b9c527f8257c4
parent8f238788de8fddd08c63a3437029ddfe19a9ee52 (diff)
Compile resource objects of the static library using same options
Introduce the function that appends the specified properties of the one target to the another. It's possible to copy the standard property set that affects a compilation only or pass some specific properties that need to copy. You may also control the visibily of properties that need to copy by passing the PRIVATE_ONLY or INTERFACE_ONLY option. The function is used to compile the resource targets with the same property set as the main target. Also link the Qt::Platform interface library to collect platform specific properties. Pick-to: 6.1 Change-Id: I727fd0a4bc52c4f5128f28ce796d7a5f3005bb30 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--src/corelib/Qt6CoreMacros.cmake53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 30c34f72e6..d6a06d930d 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1329,6 +1329,10 @@ function(__qt_propagate_generated_resource target resource_name generated_source
target_compile_definitions("${resource_target}" PRIVATE
"$<TARGET_PROPERTY:${QT_CMAKE_EXPORT_NAMESPACE}::Core,INTERFACE_COMPILE_DEFINITIONS>"
)
+
+ target_link_libraries(${resource_target} PRIVATE ${QT_CMAKE_EXPORT_NAMESPACE}::Platform)
+ _qt_internal_copy_dependency_properties(${resource_target} ${target} PRIVATE_ONLY)
+
# Special handling is required for the Core library resources. The linking of the Core
# library to the resources adds a circular dependency. This leads to the wrong
# objects/library order in the linker command line, since the Core library target is resolved
@@ -1715,3 +1719,52 @@ function(_qt_internal_apply_strict_cpp target)
endif()
endif()
endfunction()
+
+# Copies properties of the dependency to the target.
+# Arguments:
+# PROPERTIES list of properties to copy. If not specified the following properties are copied
+# by default: INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES COMPILE_DEFINITIONS
+# COMPILE_OPTIONS COMPILE_FEATURES
+# PRIVATE_ONLY copy only private properties (without INTERFACE analogues). Optional.
+# INTERFACE_ONLY copy only interface properties (without non-prefixed analogues). Optional.
+# Note: Not all properties have INTERFACE properties analogues.
+# See https://cmake.org/cmake/help/latest/prop_tgt/EXPORT_PROPERTIES.html for details.
+#
+# PRIVATE_ONLY and INTERFACE_ONLY in the same call are not allowed. Omit these options to copy
+# both sets.
+function(_qt_internal_copy_dependency_properties target dependency)
+ cmake_parse_arguments(arg "INTERFACE_ONLY;PRIVATE_ONLY" "" "PROPERTIES" ${ARGN})
+ if(arg_PRIVATE_ONLY AND arg_INTERFACE_ONLY)
+ message("Both PRIVATE_ONLY and INTERFACE_ONLY options are set.\
+Please use _qt_internal_copy_dependency_properties without these options to copy a set of
+properties of both types."
+ )
+ endif()
+
+ if(arg_PROPERTIES)
+ set(common_props_to_set ${arg_PROPERTIES})
+ else()
+ set(common_props_to_set
+ INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES
+ COMPILE_DEFINITIONS COMPILE_OPTIONS
+ COMPILE_FEATURES
+ )
+ endif()
+
+ set(props_to_set "")
+ if(NOT arg_INTERFACE_ONLY)
+ set(props_to_set ${common_props_to_set})
+ endif()
+ if(NOT arg_PRIVATE_ONLY)
+ list(TRANSFORM common_props_to_set PREPEND INTERFACE_
+ OUTPUT_VARIABLE interface_properties)
+ list(APPEND props_to_set ${interface_properties})
+ endif()
+
+ foreach(prop ${props_to_set})
+ set_property(TARGET
+ "${target}" APPEND PROPERTY
+ ${prop} "$<TARGET_PROPERTY:${dependency},${prop}>"
+ )
+ endforeach()
+endfunction()