summaryrefslogtreecommitdiffstats
path: root/Tests/ObjectLibrary
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-14 17:45:06 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-14 19:50:08 (GMT)
commit50fdaf8f1f6e34d9362b679df0a26d6bbf77c0ba (patch)
treed6a62f015df772ea882e77cffdcc4f6f37f8efc8 /Tests/ObjectLibrary
parent0e26bd334db07e481e5585f5121fb7e9718e9c47 (diff)
downloadCMake-50fdaf8f1f6e34d9362b679df0a26d6bbf77c0ba.zip
CMake-50fdaf8f1f6e34d9362b679df0a26d6bbf77c0ba.tar.gz
CMake-50fdaf8f1f6e34d9362b679df0a26d6bbf77c0ba.tar.bz2
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>
Diffstat (limited to 'Tests/ObjectLibrary')
-rw-r--r--Tests/ObjectLibrary/CMakeLists.txt2
-rw-r--r--Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt15
-rw-r--r--Tests/ObjectLibrary/TransitiveLinkDeps/dep.c4
-rw-r--r--Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c6
-rw-r--r--Tests/ObjectLibrary/TransitiveLinkDeps/main.c6
5 files changed, 33 insertions, 0 deletions
diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt
index b57761b..2bc2327 100644
--- a/Tests/ObjectLibrary/CMakeLists.txt
+++ b/Tests/ObjectLibrary/CMakeLists.txt
@@ -77,3 +77,5 @@ add_subdirectory(ExportLanguages)
add_subdirectory(LinkObjects)
add_subdirectory(Transitive)
+
+add_subdirectory(TransitiveLinkDeps)
diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt b/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt
new file mode 100644
index 0000000..3f561fa
--- /dev/null
+++ b/Tests/ObjectLibrary/TransitiveLinkDeps/CMakeLists.txt
@@ -0,0 +1,15 @@
+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)
diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/dep.c b/Tests/ObjectLibrary/TransitiveLinkDeps/dep.c
new file mode 100644
index 0000000..7cc62c3
--- /dev/null
+++ b/Tests/ObjectLibrary/TransitiveLinkDeps/dep.c
@@ -0,0 +1,4 @@
+int from_dep(void)
+{
+ return 0;
+}
diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c b/Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c
new file mode 100644
index 0000000..f5760b7
--- /dev/null
+++ b/Tests/ObjectLibrary/TransitiveLinkDeps/impl_obj.c
@@ -0,0 +1,6 @@
+int from_dep(void);
+
+int impl_obj(void)
+{
+ return from_dep();
+}
diff --git a/Tests/ObjectLibrary/TransitiveLinkDeps/main.c b/Tests/ObjectLibrary/TransitiveLinkDeps/main.c
new file mode 100644
index 0000000..5661f57
--- /dev/null
+++ b/Tests/ObjectLibrary/TransitiveLinkDeps/main.c
@@ -0,0 +1,6 @@
+int impl_obj(void);
+
+int main(int argc, char* argv[])
+{
+ return impl_obj();
+}