diff options
author | Matthew Waters <matthew@centricular.com> | 2016-09-11 12:07:28 +1000 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-09-26 20:25:17 +0300 |
commit | 13e91ab4996ffd3e3ebc24e7a69ccba64e89b4f5 (patch) | |
tree | 680fb482e7379093fbe913dbbafc088bb90573a6 /test cases/linuxlike | |
parent | 5ebc77f72223d15fae869ffcc26c0b0020198fc4 (diff) | |
download | meson-13e91ab4996ffd3e3ebc24e7a69ccba64e89b4f5.zip meson-13e91ab4996ffd3e3ebc24e7a69ccba64e89b4f5.tar.gz meson-13e91ab4996ffd3e3ebc24e7a69ccba64e89b4f5.tar.bz2 |
Add dependency support to the checks using the compiler
It is extremely common to need to know within a given dependency if
a given header, symbol, member, function, etc exists that cannot be
determined from the version number alone.
Without passing dependency objects to the various compiler/linker
checks and with many libraries headers/libraries being located in
their own subdirs of the standard prefix, the check for the library
would not find the header/function/symbol/etc.
This commit allows passing dependency objects to the compiler checks so
that the test program can be compiled/linked/run with the necessary
compilation and/or linking flags for that library.
Diffstat (limited to 'test cases/linuxlike')
-rw-r--r-- | test cases/linuxlike/9 compiler checks with dependencies/meson.build | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test cases/linuxlike/9 compiler checks with dependencies/meson.build b/test cases/linuxlike/9 compiler checks with dependencies/meson.build new file mode 100644 index 0000000..2aa9015 --- /dev/null +++ b/test cases/linuxlike/9 compiler checks with dependencies/meson.build @@ -0,0 +1,31 @@ +project('compiler checks with dependencies', 'c') + +cc = meson.get_compiler('c') + +glib = dependency ('glib-2.0') +if glib.found() + assert (cc.has_header('glib.h', dependencies : glib), 'glib.h not found') + assert (cc.has_type('gint32', prefix : '#include <glib.h>', dependencies : glib), 'gint32 not found') + assert (cc.has_function('g_print', dependencies : glib), 'g_print not found') + assert (cc.has_member('GError', 'message', prefix : '#include <glib.h>', dependencies : glib), 'GError::message not found') + assert (cc.has_header_symbol('glib.h', 'gint32', dependencies : glib), 'gint32 symbol not found') + linkcode = '''#include <glib.h> +int main (int argc, char *argv[]) { + GError *error = g_error_new_literal (0, 0, NULL); + return error == NULL; +} + ''' + assert (cc.links(linkcode, dependencies : glib, name : 'Test link against glib'), 'Linking test against glib failed') +endif + +zlib = cc.find_library ('z') +if zlib.found() + linkcode = '''#include<zlib.h> +int main(int argc, char *argv[]) { + void *ptr = (void*)(deflate); + return ptr == 0; +} +''' + assert (cc.has_function('deflate', prefix : '#include<zlib.h>', dependencies : zlib, name : 'Test for function in zlib'), 'has_function test failed.') + assert (cc.links(linkcode, dependencies : zlib, name : 'Test link against zlib'), 'Linking test failed against zlib.') +endif |