meson.build 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. project('check header', 'c', 'cpp')
  2. host_system = host_machine.system()
  3. non_existant_header = 'ouagadougou.h'
  4. # Copy it into the builddir to ensure that it isn't found even if it's there
  5. configure_file(input : non_existant_header,
  6. output : non_existant_header,
  7. copy: true)
  8. fallback = ''
  9. foreach comp : [meson.get_compiler('c'), meson.get_compiler('cpp')]
  10. assert(comp.check_header('stdio.h', prefix : fallback), 'Stdio missing.')
  11. # stdio.h doesn't actually need stdlib.h, but just test that setting the
  12. # prefix does not result in an error.
  13. assert(comp.check_header('stdio.h', prefix : '#include <stdlib.h>' + fallback),
  14. 'Stdio missing.')
  15. # Test that check_header behaves differently than has_header. The second
  16. # check without windows.h will fail with check_header.
  17. # We only do this check on MSVC because MinGW often defines its own wrappers
  18. # that pre-include windows.h
  19. if comp.get_id() == 'msvc'
  20. assert(comp.check_header('XInput.h', prefix : '#include <windows.h>' + fallback),
  21. 'XInput.h should not be missing on Windows')
  22. assert(not comp.check_header('XInput.h'), 'XInput.h needs windows.h')
  23. endif
  24. # Test that the following GCC bug doesn't happen:
  25. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80005
  26. # https://github.com/mesonbuild/meson/issues/1458
  27. if host_system == 'linux'
  28. assert(comp.check_header('linux/socket.h', prefix : fallback),
  29. 'Could not find <linux/socket.h>')
  30. if comp.has_header('intrin.h', prefix : fallback)
  31. assert(not comp.check_header('intrin.h'),
  32. 'intrin.h should not be usable on linux')
  33. endif
  34. endif
  35. # This header exists in the source and the builddir, but we still must not
  36. # find it since we are looking in the system directories.
  37. assert(not comp.check_header(non_existant_header, prefix : fallback),
  38. 'Found non-existant header.')
  39. endforeach