a833aa1167 Fix dependencies on targets linked through object libraries
3b3de0fd17 Tests: Extend ObjectLibrary test with case for object lib dependencies
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4427
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 commit bab24e782c
(target_link_libraries: Propagate dependencies of object libraries,
2018-12-10, v3.14.0-rc1~260^2) 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 commit ea0a060168
(fileapi: Add test for codemodel v2, 2018-11-09, v3.14.0-rc1~257^2~7).
That comment itself was dropped by commit a0de350e2f (FileAPI test:
Break gen_check_targets() into JSON files, 2020-02-07), but we can now
update the corresponding location in the `.json` files to have the
now-expected backtrace information.
Fixes: #20421
Add the test case from commit bab24e782c (target_link_libraries:
Propagate dependencies of object libraries, 2018-12-10,
v3.14.0-rc1~260^2) to the main ObjectLibrary test.
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 6af2e59217a7e10ed507da564a1445b60ac2a095 (master).
Upstream Shortlog
-----------------
Hans Johnson (17):
81d1e737 STYLE: Use modern path naming
28b8e6c2 STYLE: Convert CMake-language commands to lower case
6ce3d69a DOC: Update documentation for modern add_subdirectory.
8a7fe7ac STYLE: Remove redundant void argument lists
1c3e193d COMP: Use nullptr instead of 0 or NULL
2a4c1252 STYLE: Replace integer literals which are cast to bool.
0fe7214d STYLE: Make prototype match definition names
3b30d0ff STYLE: Make prototype match definition names
691d5612 PERF: readability container size empty
7be4043f STYLE: Prefer c++11 'using' to 'typedef'
acc916ed COMP: Prefer const pointer when value does not change
4c7f64eb COMP: Prefer const member functions
d07092a0 STYLE: Use default member initialization
6d20e7c9 STYLE: Prefer = default to explicitly trivial implementations
91429382 PERF: emplace_back method results in potentially more efficient code
cc8fc323 STYLE: Use auto for variable type matches the type of the initializer
6621b069 STYLE: Use range-based loops from C++11
Julien Schueller (1):
a1a261ac CMake: Fix psapi lib name on case-sensitive fs
If cross-config mode is used, and a target depends on another target
as well as a custom command, we don't want the custom command to also
depend on the depended target, as that would build targets unnecessarily.
Fix this behavior.
`link.exe /lib` is an undocumented flag and it just calls `lib.exe`.
Also `link.exe` doesn't parse the `/lib` option correctly when in a
response file.
Since commit 1c2d031cbd (Add -E cmake_llvm_rc to preprocess files for
llvm-rc, 2020-01-14, v3.17.0-rc1~24^2) we pass the full target `<FLAGS>`
to the llvm-rc resource compiler, but we should pass only `<DEFINES>`.
Fixes: #20414