diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-03 13:51:48 +0200 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-10 15:17:55 +0200 |
commit | 4e901a2f99cbfda3b479253ea54b16f02e1c3aa5 (patch) | |
tree | b4567bb4dfb970c038e56c5dc86496c266c2668b /src/corelib | |
parent | 60e104aed84759f1e0cf324f47781eed5b055761 (diff) |
Add the check for linker capabilities to resolve circular dependencies
'ld' only capable to resolve circular dependencies by wrapping the
suspected static libraries and objects using --start/end-group
arguments. We want to detect if linker is 'ld' at configure time to
decide how to link the resource objects if finalizers are not enabled.
The qt_config_compile_test function is extended with an extra argument
since it's required to pass custom cmake flags to the ld-related test.
Pick-to: 6.2
Change-Id: I484fcc99e2886952d8b0232f37e4e6a35d072931
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 819fbbfb9c..3c154f4587 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1479,10 +1479,24 @@ function(__qt_propagate_generated_resource target resource_name generated_source "$<NOT:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>>" ) set(resource_objects "$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>") - target_link_libraries(${target} INTERFACE + + set(resource_linking_args ${target} INTERFACE "$<$<AND:${finalizer_mode_condition},${not_static_condition}>:${resource_objects}>" ) + # TODO: The QT_LINK_ORDER_MATTERS flag is not defined for user projects. + # It makes sense to disable finalizers if linker may resolve circular dependencies + # between objects and static libraries. + # Follow-up changes should set _qt_resource_objects_finalizer_mode to FALSE by default + # and use target_link_libraries for user projects if the order doesn't affect the + # linker work. + get_property(link_order_matters GLOBAL PROPERTY QT_LINK_ORDER_MATTERS) + if(link_order_matters) + target_sources(${resource_linking_args}) + else() + target_link_libraries(${resource_linking_args}) + endif() + if(NOT target STREQUAL "Core") # It's necessary to link the object library target, since we want to pass # the object library dependencies to the 'target'. Interface linking doesn't |