meson.build 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. project('has header symbol', 'c', 'cpp')
  2. cc = meson.get_compiler('c')
  3. cpp = meson.get_compiler('cpp')
  4. foreach comp : [cc, cpp]
  5. assert (comp.has_header_symbol('stdio.h', 'int'), 'base types should always be available')
  6. assert (comp.has_header_symbol('stdio.h', 'printf'), 'printf function not found')
  7. assert (comp.has_header_symbol('stdio.h', 'FILE'), 'FILE structure not found')
  8. assert (comp.has_header_symbol('limits.h', 'INT_MAX'), 'INT_MAX define not found')
  9. assert (not comp.has_header_symbol('limits.h', 'guint64'), 'guint64 is not defined in limits.h')
  10. assert (not comp.has_header_symbol('stdlib.h', 'FILE'), 'FILE structure is defined in stdio.h, not stdlib.h')
  11. assert (not comp.has_header_symbol('stdlol.h', 'printf'), 'stdlol.h shouldn\'t exist')
  12. assert (not comp.has_header_symbol('stdlol.h', 'int'), 'shouldn\'t be able to find "int" with invalid header')
  13. endforeach
  14. # This is available on Glibc, Solaris & the BSD's, so just test for _GNU_SOURCE
  15. # on Linux
  16. if cc.has_function('ppoll') and host_machine.system() == 'linux'
  17. assert (not cc.has_header_symbol('poll.h', 'ppoll'), 'ppoll should not be accessible without _GNU_SOURCE')
  18. assert (cc.has_header_symbol('poll.h', 'ppoll', prefix : '#define _GNU_SOURCE'), 'ppoll should be accessible with _GNU_SOURCE')
  19. endif
  20. assert (cpp.has_header_symbol('iostream', 'std::iostream'), 'iostream not found in iostream.h')
  21. assert (cpp.has_header_symbol('vector', 'std::vector'), 'vector not found in vector.h')
  22. assert (not cpp.has_header_symbol('limits.h', 'std::iostream'), 'iostream should not be defined in limits.h')
  23. # Cross compilation and boost do not mix.
  24. if not meson.is_cross_build()
  25. boost = dependency('boost', required : false)
  26. if boost.found()
  27. assert (cpp.has_header_symbol('boost/math/quaternion.hpp', 'boost::math::quaternion', dependencies : boost), 'quaternion not found')
  28. else
  29. assert (not cpp.has_header_symbol('boost/math/quaternion.hpp', 'boost::math::quaternion', dependencies : boost), 'quaternion found?!')
  30. endif
  31. endif