meson.build 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. project('compiler checks with dependencies', 'c')
  2. cc = meson.get_compiler('c')
  3. glib = dependency ('glib-2.0')
  4. if glib.found()
  5. assert (cc.has_header('glib.h', dependencies : glib), 'glib.h not found')
  6. assert (cc.has_type('gint32', prefix : '#include <glib.h>', dependencies : glib), 'gint32 not found')
  7. assert (cc.has_function('g_print', dependencies : glib), 'g_print not found')
  8. assert (cc.has_member('GError', 'message', prefix : '#include <glib.h>', dependencies : glib), 'GError::message not found')
  9. assert (cc.has_header_symbol('glib.h', 'gint32', dependencies : glib), 'gint32 symbol not found')
  10. linkcode = '''#include <glib.h>
  11. int main (int argc, char *argv[]) {
  12. GError *error = g_error_new_literal (0, 0, NULL);
  13. return error == NULL;
  14. }
  15. '''
  16. assert (cc.links(linkcode, dependencies : glib, name : 'Test link against glib'), 'Linking test against glib failed')
  17. endif
  18. zlib = cc.find_library ('z')
  19. if zlib.found()
  20. linkcode = '''#include<zlib.h>
  21. int main(int argc, char *argv[]) {
  22. void *ptr = (void*)(deflate);
  23. return ptr == 0;
  24. }
  25. '''
  26. assert (cc.has_function('deflate', prefix : '#include<zlib.h>', dependencies : zlib, name : 'Test for function in zlib'), 'has_function test failed.')
  27. assert (cc.links(linkcode, dependencies : zlib, name : 'Test link against zlib'), 'Linking test failed against zlib.')
  28. endif