Switch to target_sources approach for the static library resources
Linking the object resource library to the static library still causes an issue if the static library contains symbols that are used in the resource library. The proposed approach creates the following linker chain: executable <- resource objects <- static library <- Qt::Core For the static qml plugins this means that the qmlcache_loader object file will state in the linker command line before the plugin library that implements '::qmlData' and '::aotBuiltFunctions' functions. We also need to keep the INTERFACE linking of the resource library to the targets that it belongs too, to collect all the dependencies that resouce library supposed to propagate to top-level targets. Pick-to: 6.1 Fixes: QTBUG-93002 Change-Id: Ice0aabb6817317724abeb3db3bb8a954905cfad1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
b5e9130c44
commit
ddaa7150d8
@ -1351,22 +1351,17 @@ function(__qt_propagate_generated_resource target resource_name generated_source
|
|||||||
|
|
||||||
# Use TARGET_NAME genex to map to the correct prefixed target name when it is exported
|
# Use TARGET_NAME genex to map to the correct prefixed target name when it is exported
|
||||||
# via qt_install(EXPORT), so that the consumers of the target can find the object library
|
# via qt_install(EXPORT), so that the consumers of the target can find the object library
|
||||||
# as well. It's also necessary to link the object library target, since we want to pass
|
# as well.
|
||||||
# the object library dependencies to the target.
|
target_sources(${target} INTERFACE
|
||||||
|
"$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>"
|
||||||
|
)
|
||||||
if(NOT target STREQUAL "Core")
|
if(NOT target STREQUAL "Core")
|
||||||
target_link_libraries(${target} INTERFACE
|
# It's necessary to link the object library target, since we want to pass
|
||||||
"$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>"
|
# the object library dependencies to the 'target'. Interface linking doesn't
|
||||||
${resource_target}
|
# add the objects of the resource library to the end-point linker line
|
||||||
)
|
# but propagates all the dependencies of the resource_target added before
|
||||||
else()
|
# or AFTER the line below.
|
||||||
# Since linking of the Core library to the own resources adds a circular dependency
|
target_link_libraries(${target} INTERFACE ${resource_target})
|
||||||
# we need to add the Core library resources as the target sources but not link the
|
|
||||||
# resource objects to the Core library. This places the resource objects to the
|
|
||||||
# correct position in linker line, but doesn't affect correctness of the Core library
|
|
||||||
# exports.
|
|
||||||
target_sources(${target} INTERFACE
|
|
||||||
"$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
set(${output_generated_target} "${resource_target}" PARENT_SCOPE)
|
set(${output_generated_target} "${resource_target}" PARENT_SCOPE)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user