summaryrefslogtreecommitdiffstats
path: root/test cases/linuxlike/2 external library
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/linuxlike/2 external library
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/linuxlike/2 external library')
-rw-r--r--test cases/linuxlike/2 external library/meson.build43
-rw-r--r--test cases/linuxlike/2 external library/prog.c8
2 files changed, 51 insertions, 0 deletions
diff --git a/test cases/linuxlike/2 external library/meson.build b/test cases/linuxlike/2 external library/meson.build
new file mode 100644
index 0000000..3188ebf
--- /dev/null
+++ b/test cases/linuxlike/2 external library/meson.build
@@ -0,0 +1,43 @@
+project('external library', 'c')
+
+cc = meson.get_compiler('c')
+zlib = cc.find_library('z')
+
+# Verify that link testing works.
+linkcode = '''#include<zlib.h>
+int main(void) {
+ void *ptr = (void*)(deflate);
+ return ptr == 0;
+}
+'''
+
+nolinkcode='''int nonexisting();
+int main(void) {
+ return nonexisting();
+}
+'''
+
+assert(cc.links(linkcode, args : '-lz', name : 'Test link against zlib'), 'Linking test failed.')
+d1 = declare_dependency(compile_args: '-DSOMETHING', link_args: '-lz')
+assert(cc.links(linkcode, dependencies : d1,
+ name : 'Test link against zlib via declare_dependency'), 'Linking test failed.')
+d2 = declare_dependency(dependencies: d1)
+assert(cc.links(linkcode, dependencies : d2,
+ name : 'Test link against zlib via indirect declare_dependency'), 'Linking test failed.')
+assert(not cc.links(nolinkcode, name : 'Failing link'), 'Linking succeeded when it should have failed.')
+
+e = executable('zprog', 'prog.c', dependencies : zlib)
+test('libtest', e)
+
+e2 = executable('zprog_alt', 'prog.c', dependencies : zlib)
+test('libtest_alt', e2)
+
+# Test that ext deps work via an internal dep.
+intdep = declare_dependency(dependencies : zlib)
+exe2 = executable('zprog2', 'prog.c', dependencies : intdep)
+test('libtest2', exe2)
+
+# Test that deps that use find_library deps work.
+depdep = declare_dependency(dependencies : intdep)
+exe3 = executable('zprog3', 'prog.c', dependencies : depdep)
+test('libtest3', exe3)
diff --git a/test cases/linuxlike/2 external library/prog.c b/test cases/linuxlike/2 external library/prog.c
new file mode 100644
index 0000000..eccc477
--- /dev/null
+++ b/test cases/linuxlike/2 external library/prog.c
@@ -0,0 +1,8 @@
+#include<zlib.h>
+
+int main(void) {
+ void * something = deflate;
+ if(something != 0)
+ return 0;
+ return 1;
+}