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. Fixes: QTBUG-93002 Change-Id: Ice0aabb6817317724abeb3db3bb8a954905cfad1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit ddaa7150d85624ab545ccfe098fe8b2d18241940)
This commit is contained in:
parent
1219dbb9f3
commit
f5047e785b
@ -1348,22 +1348,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
|
||||
# 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
|
||||
# the object library dependencies to the target.
|
||||
# as well.
|
||||
target_sources(${target} INTERFACE
|
||||
"$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>"
|
||||
)
|
||||
if(NOT target STREQUAL "Core")
|
||||
target_link_libraries(${target} INTERFACE
|
||||
"$<TARGET_OBJECTS:$<TARGET_NAME:${resource_target}>>"
|
||||
${resource_target}
|
||||
)
|
||||
else()
|
||||
# Since linking of the Core library to the own resources adds a circular dependency
|
||||
# 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}>>"
|
||||
)
|
||||
# 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
|
||||
# add the objects of the resource library to the end-point linker line
|
||||
# but propagates all the dependencies of the resource_target added before
|
||||
# or AFTER the line below.
|
||||
target_link_libraries(${target} INTERFACE ${resource_target})
|
||||
endif()
|
||||
set(${output_generated_target} "${resource_target}" PARENT_SCOPE)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user