summaryrefslogtreecommitdiff
path: root/Tests/ObjectLibrary/LinkObjects/main.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-26 10:56:10 -0400
committerBrad King <brad.king@kitware.com>2021-05-29 09:28:36 -0400
commit3941555d935afad8343c66f39579bfc611201a6f (patch)
tree4f5b55b32aa25a56fb6f6f10ba896585878e6331 /Tests/ObjectLibrary/LinkObjects/main.c
parentf530b3a26729d0820c804e312b72e0061d6eeb4b (diff)
downloadcmake-3941555d935afad8343c66f39579bfc611201a6f.tar.gz
target_link_libraries: Place $<TARGET_OBJECTS> before libraries
Linkers always use object files explicitly specified on the command line regardless of where they appear. Move them to the front of the list of linked libraries in so that symbols required by the object files can be resolved by any library. Issue: #22149
Diffstat (limited to 'Tests/ObjectLibrary/LinkObjects/main.c')
-rw-r--r--Tests/ObjectLibrary/LinkObjects/main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/ObjectLibrary/LinkObjects/main.c b/Tests/ObjectLibrary/LinkObjects/main.c
new file mode 100644
index 0000000000..c09c4f11bd
--- /dev/null
+++ b/Tests/ObjectLibrary/LinkObjects/main.c
@@ -0,0 +1,24 @@
+#ifdef OBJA
+# error "OBJA is defined, but should not be"
+#endif
+#ifndef OBJB
+# error "OBJB is not defined, but should be"
+#endif
+#ifdef OBJC
+# error "OBJC is defined, but should not be"
+#endif
+#ifndef OBJD
+# error "OBJD is not defined, but should be"
+#endif
+#ifdef OBJE
+# error "OBJE is defined, but should not be"
+#endif
+extern int a_obj(void);
+extern int b_obj(void);
+extern int c_obj(void);
+extern int d_obj(void);
+extern int e_lib(void);
+int main(void)
+{
+ return a_obj() + b_obj() + c_obj() + d_obj() + e_lib();
+}