| 1 |
# SPDX-License-Identifier: Apache-2.0 |
| 2 |
# Copyright © 2024 Intel Corporation |
| 3 |
|
| 4 |
project( |
| 5 |
'has header symbol', |
| 6 |
'c', 'cpp', |
| 7 |
default_options : ['cpp_std=c++14'], |
| 8 |
) |
| 9 |
|
| 10 |
cc = meson.get_compiler('c') |
| 11 |
cpp = meson.get_compiler('cpp') |
| 12 |
|
| 13 |
foreach comp : [cc, cpp] |
| 14 |
assert (comp.has_header_symbol('stdio.h', 'int'), 'base types should always be available') |
| 15 |
assert (comp.has_header_symbol('stdio.h', 'printf'), 'printf function not found') |
| 16 |
assert (comp.has_header_symbol('stdio.h', 'FILE'), 'FILE structure not found') |
| 17 |
assert (comp.has_header_symbol('limits.h', 'INT_MAX'), 'INT_MAX define not found') |
| 18 |
assert (not comp.has_header_symbol('limits.h', 'guint64'), 'guint64 is not defined in limits.h') |
| 19 |
assert (not comp.has_header_symbol('stdlib.h', 'FILE'), 'FILE structure is defined in stdio.h, not stdlib.h') |
| 20 |
assert (not comp.has_header_symbol('stdlol.h', 'printf'), 'stdlol.h shouldn\'t exist') |
| 21 |
assert (not comp.has_header_symbol('stdlol.h', 'int'), 'shouldn\'t be able to find "int" with invalid header') |
| 22 |
endforeach |
| 23 |
|
| 24 |
# Glibc requires _GNU_SOURCE for ppoll. Other libcs do not. |
| 25 |
if cc.has_function('ppoll') and not cc.has_header_symbol('poll.h', 'ppoll') |
| 26 |
assert (cc.has_header_symbol('poll.h', 'ppoll', prefix : '#define _GNU_SOURCE'), 'ppoll should be accessible with _GNU_SOURCE') |
| 27 |
endif |
| 28 |
|
| 29 |
assert (cpp.has_header_symbol('iostream', 'std::iostream'), 'iostream not found in iostream.h') |
| 30 |
assert (cpp.has_header_symbol('vector', 'std::vector'), 'vector not found in vector.h') |
| 31 |
assert (not cpp.has_header_symbol('limits.h', 'std::iostream'), 'iostream should not be defined in limits.h') |
| 32 |
|
| 33 |
# Cross compilation and boost do not mix. |
| 34 |
if not meson.is_cross_build() |
| 35 |
boost = dependency('boost', required : false) |
| 36 |
if boost.found() |
| 37 |
assert (cpp.has_header_symbol('boost/math/quaternion.hpp', 'boost::math::quaternion', dependencies : boost), 'quaternion not found') |
| 38 |
else |
| 39 |
assert (not cpp.has_header_symbol('boost/math/quaternion.hpp', 'boost::math::quaternion', dependencies : boost), 'quaternion found?!') |
| 40 |
endif |
| 41 |
endif |