diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-12 19:11:42 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-03-12 19:11:42 +0530 |
commit | b8b05497af4d6f2189fe35eb04c514b5a42893b4 (patch) | |
tree | 24c041def8245f48b6b9ea3d72dc678a612a2ce0 | |
parent | 1612dbd719cafc88db2da098a035c82456e4c638 (diff) | |
download | meson-b8b05497af4d6f2189fe35eb04c514b5a42893b4.zip meson-b8b05497af4d6f2189fe35eb04c514b5a42893b4.tar.gz meson-b8b05497af4d6f2189fe35eb04c514b5a42893b4.tar.bz2 |
tests/37 has header: Also test the fallback include check
Also forcibly undefine __has_include and test that the fallback include
check in cc.has_header() works.
This is important because all the latest compilers support it now
and we might have no test coverage at all by accident. GCC 5, ICC 17,
Clang 3.8, and VS2015 Update 2 already support it.
-rw-r--r-- | test cases/common/37 has header/meson.build | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/test cases/common/37 has header/meson.build b/test cases/common/37 has header/meson.build index 9709183..c87f244 100644 --- a/test cases/common/37 has header/meson.build +++ b/test cases/common/37 has header/meson.build @@ -9,39 +9,41 @@ configure_file(input : non_existant_header, output : non_existant_header, configuration : configuration_data()) -foreach comp : [meson.get_compiler('c'), meson.get_compiler('cpp')] - if not comp.has_header('stdio.h') - error('Stdio missing.') - endif - - # stdio.h doesn't actually need stdlib.h, but just test that setting the - # prefix does not result in an error. - if not comp.has_header('stdio.h', prefix : '#include <stdlib.h>') - error('Stdio missing.') - endif - - # XInput.h should not require type definitions from windows.h, but it does - # require macro definitions. Specifically, it requires an arch setting for - # VS2015 at least. - # We only do this check on MSVC because MinGW often defines its own wrappers - # that pre-include windows.h - if comp.get_id() == 'msvc' - if not comp.has_header('XInput.h', prefix : '#include <windows.h>') - error('XInput.h should not be missing on Windows') +# Test that the fallback to __has_include also works on all compilers +args = [[], ['-U__has_include']] + +foreach arg : args + foreach comp : [meson.get_compiler('c'), meson.get_compiler('cpp')] + assert(comp.has_header('stdio.h', args : arg), 'Stdio missing.') + + # stdio.h doesn't actually need stdlib.h, but just test that setting the + # prefix does not result in an error. + assert(comp.has_header('stdio.h', prefix : '#include <stdlib.h>', args : arg), + 'Stdio missing.') + + # XInput.h should not require type definitions from windows.h, but it does + # require macro definitions. Specifically, it requires an arch setting for + # VS2015 at least. + # We only do this check on MSVC because MinGW often defines its own wrappers + # that pre-include windows.h + if comp.get_id() == 'msvc' + assert(comp.has_header('XInput.h', prefix : '#include <windows.h>', args : arg), + 'XInput.h should not be missing on Windows') + assert(comp.has_header('XInput.h', prefix : '#define _X86_', args : arg), + 'XInput.h should not need windows.h') endif - if not comp.has_header('XInput.h', prefix : '#define _X86_') - error('XInput.h should not need windows.h') + + # Test that the following GCC bug doesn't happen: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80005 + # https://github.com/mesonbuild/meson/issues/1458 + if host_system == 'linux' + assert(comp.has_header('linux/if.h', args : arg), + 'Could not find <linux/if.h>') endif - endif - - # Test that the following GCC bug doesn't happen: - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80005 - # https://github.com/mesonbuild/meson/issues/1458 - if host_system == 'linux' - assert(comp.has_header('linux/if.h'), 'Could not find <linux/if.h>') - endif - - # This header exists in the source and the builddir, but we still must not - # find it since we are looking in the system directories. - assert(not comp.has_header(non_existant_header), 'Found non-existant header.') + + # This header exists in the source and the builddir, but we still must not + # find it since we are looking in the system directories. + assert(not comp.has_header(non_existant_header, args : arg), + 'Found non-existant header.') + endforeach endforeach |