Fix dependencies on targets linked through object libraries
When an object library is used via target_link_libraries
, any targets
listed in the object library's INTERFACE_LINK_LIBRARIES
closure should
become direct dependencies of the consuming target. However, these were
accidentally left out by cmComputeTargetDepends::CollectTargetDepends
because object libraries are encountered through external object sources
first and then added to the emitted
set which blocks them from being
processed as link dependencies.
This was not noticed by the test case in !2725 (merged) because the relevant dependency appears transitively through the object library target itself.
Re-order the logic to process link dependencies first, and then external
object sources. That way object libraries used via
target_link_libraries
will be treated as such by dependency analysis.
This also adds missing backtrace information for object libraries used
via target_link_libraries
. The missing information was mentioned in a
FIXME comment in the RunCMake.FileAPI test added by !2706 (merged).
That comment itself was dropped by !4333 (merged), but we can now
update the corresponding location in the .json
files to have the
now-expected backtrace information.
Fixes: #20421 (closed)