Debian Codegraph @

vendored-meson/meson/test cases/common/189 check header/meson.build

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