1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 08:51:52 +08:00
Files
CMake/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt
Brad King 50fdaf8f1f cmComputeLinkInformation: Track targets named by TARGET_OBJECTS sources
Since commit b6a5382217 (Ninja: depend on language module information
files directly, 2023-02-10, v3.27.0-rc1~502^2), the return value of
`cmCommonTargetGenerator::GetLinkedTargetDirectories` must account for
linked object libraries because they may provide modules (#25112).
These were added by commit b665966933 (cmComputeLinkInformation: track
OBJECT library dependencies, 2023-07-22, v3.27.1~5^2).  However, targets
named by `$<TARGET_OBJECTS:...>` sources are also needed (#25365).

The latter were added by commit 22da18b995 (Fortran: Restore support for
TARGET_OBJECTS providing modules, 2023-10-27, v3.28.0-rc4~9^2) and
commit 035302b7e3 (cmComputeLinkDepends: also copy the target from
object link items, 2023-10-27, v3.28.0-rc4~9^2~2).  However, their
approach added link entries not actually specified by projects.  It also
incorrectly re-used `cmComputeLinkDepends::AddLinkObject` for object
library targets when it is meant for their individual object files.
These problems caused additional regressions (#25417).  Revert the
implementation parts of those commits and leave behind an assertion and
comment to help avoid the mistake in the future.  Instead, track targets
named by `$<TARGET_OBJECTS:...>` sources with a dedicated member.

Issue: #25112
Issue: #25365
Fixes: #25417
Co-authored-by: Ben Boeckel <ben.boeckel@kitware.com>
2023-11-14 14:50:08 -05:00

16 lines
423 B
CMake

add_library(implgather INTERFACE)
add_library(dep STATIC dep.c)
add_library(deps INTERFACE)
target_link_libraries(deps INTERFACE dep)
add_library(impl_obj OBJECT impl_obj.c)
target_link_libraries(impl_obj PUBLIC deps)
target_sources(implgather INTERFACE "$<TARGET_OBJECTS:impl_obj>")
target_link_libraries(implgather INTERFACE impl_obj)
add_executable(useimpl main.c)
target_link_libraries(useimpl PRIVATE implgather)