diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 53d115a6da..30c34f72e6 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -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 # 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 + "$>" + ) if(NOT target STREQUAL "Core") - target_link_libraries(${target} INTERFACE - "$>" - ${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 - "$>" - ) + # 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)