Debian Codegraph @

test cases/linuxlike/9 compiler checks with dependencies/meson.build

raw
1 project('compiler checks with dependencies', 'c')
2
3 cc = meson.get_compiler('c')
4
5 glib = dependency ('glib-2.0')
6 if glib.found()
7 assert (cc.has_header('glib.h', dependencies : glib), 'glib.h not found')
8 assert (cc.has_type('gint32', prefix : '#include <glib.h>', dependencies : glib), 'gint32 not found')
9 assert (cc.has_function('g_print', dependencies : glib), 'g_print not found')
10 assert (cc.has_member('GError', 'message', prefix : '#include <glib.h>', dependencies : glib), 'GError::message not found')
11 assert (cc.has_header_symbol('glib.h', 'gint32', dependencies : glib), 'gint32 symbol not found')
12 linkcode = '''#include <glib.h>
13 int main (void) {
14 GError *error = g_error_new_literal (0, 0, NULL);
15 return error == NULL;
16 }
17 '''
18 assert (cc.links(linkcode, dependencies : glib, name : 'Test link against glib'), 'Linking test against glib failed')
19 endif
20
21 zlib = cc.find_library ('z')
22 if zlib.found()
23 linkcode = '''#include<zlib.h>
24 int main(void) {
25 void *ptr = (void*)(deflate);
26 return ptr == 0;
27 }
28 '''
29 assert (cc.has_function('deflate', prefix : '#include<zlib.h>', dependencies : zlib), 'has_function test failed.')
30 assert (cc.links(linkcode, dependencies : zlib, name : 'Test link against zlib'), 'Linking test failed against zlib.')
31 endif
32
33 assert(cc.has_function('pthread_create',
34 dependencies : dependency('threads'),
35 prefix : '#include <pthread.h>'),
36 'Could not detect pthread_create with a thread dependency.')