summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorL. E. Segovia <amy@amyspark.me>2024-01-16 23:06:04 -0300
committerDylan Baker <dylan@pnwbakers.com>2024-04-05 15:11:52 -0700
commitd86fce9594bd942da681aac3c8041202a7c38938 (patch)
tree7af07ee54cb6a1a816f54de7f7b8e15b066a3ebe
parent82399123797a838d92b60cdc0e56e1b34536aea6 (diff)
downloadmeson-d86fce9594bd942da681aac3c8041202a7c38938.tar.gz
compilers: Add test for detecting libraries with externally supplied linker flags
-rw-r--r--test cases/windows/22 msvc library argument order/lib/.gitignore2
-rw-r--r--test cases/windows/22 msvc library argument order/meson.build33
-rw-r--r--test cases/windows/22 msvc library argument order/nativefile.ini.in9
-rw-r--r--test cases/windows/22 msvc library argument order/source.c3
4 files changed, 47 insertions, 0 deletions
diff --git a/test cases/windows/22 msvc library argument order/lib/.gitignore b/test cases/windows/22 msvc library argument order/lib/.gitignore
new file mode 100644
index 000000000..b072cc190
--- /dev/null
+++ b/test cases/windows/22 msvc library argument order/lib/.gitignore
@@ -0,0 +1,2 @@
+*.obj
+*.lib
diff --git a/test cases/windows/22 msvc library argument order/meson.build b/test cases/windows/22 msvc library argument order/meson.build
new file mode 100644
index 000000000..39a6efe7b
--- /dev/null
+++ b/test cases/windows/22 msvc library argument order/meson.build
@@ -0,0 +1,33 @@
+project('can-this-find-an-external-library', 'c')
+
+cc = meson.get_compiler('c')
+
+if cc.get_argument_syntax() != 'msvc'
+ error('MESON_SKIP_TEST: test is only relevant for msvc and clang-cl')
+endif
+
+# We need to conjure a static library for the current architecture
+# Generate an object file manually.
+run_command(
+ [
+ meson.get_compiler('c').cmd_array().get(-1),
+ '/nologo',
+ '/MDd',
+ '/Fo@0@'.format(meson.current_source_dir() / 'lib' / 'source.obj'),
+ '/c',
+ files('source.c'),
+ ],
+ check: true
+)
+# Turn it into a library.
+run_command(
+ [
+ find_program('LIB'),
+ '/OUT:@0@'.format(meson.current_source_dir() / 'lib' / 'conjured.lib'),
+ meson.current_source_dir() / 'lib' / 'source.obj',
+ ],
+ check: true
+)
+
+# Ensure this library can be found
+dep = cc.find_library('conjured', required: true)
diff --git a/test cases/windows/22 msvc library argument order/nativefile.ini.in b/test cases/windows/22 msvc library argument order/nativefile.ini.in
new file mode 100644
index 000000000..2beab5148
--- /dev/null
+++ b/test cases/windows/22 msvc library argument order/nativefile.ini.in
@@ -0,0 +1,9 @@
+[constants]
+common_args = ['-I@MESON_TEST_ROOT@/include']
+common_link_args = ['-LIBPATH:@MESON_TEST_ROOT@/lib']
+
+[properties]
+c_args = common_args
+cpp_args = common_args
+c_link_args = common_link_args
+cpp_link_args = common_link_args
diff --git a/test cases/windows/22 msvc library argument order/source.c b/test cases/windows/22 msvc library argument order/source.c
new file mode 100644
index 000000000..1dc08e168
--- /dev/null
+++ b/test cases/windows/22 msvc library argument order/source.c
@@ -0,0 +1,3 @@
+int func1_in_obj(void) {
+ return 0;
+}