A library without its headers is often useless, so it is common to check them together.pull/4672/head
parent
ff2aa5a9ef
commit
b6cede2928
5 changed files with 86 additions and 34 deletions
@ -0,0 +1,21 @@ |
||||
## Find library with its headers |
||||
|
||||
The `find_library()` method can now also verify if the library's headers are |
||||
found in a single call, using the `has_header()` method internally. |
||||
|
||||
```meson |
||||
# Aborts if the 'z' library is found but not its header file |
||||
zlib = find_library('z', has_headers : 'zlib.h') |
||||
# Returns not-found if the 'z' library is found but not its header file |
||||
zlib = find_library('z', has_headers : 'zlib.h', required : false) |
||||
``` |
||||
|
||||
Any keyword argument with the `header_` prefix passed to `find_library()` will |
||||
be passed to the `has_header()` method with the prefix removed. |
||||
|
||||
```meson |
||||
libfoo = find_library('foo', |
||||
has_headers : ['foo.h', 'bar.h'], |
||||
header_prefix : '#include <baz.h>', |
||||
header_include_directories : include_directories('.')) |
||||
``` |
@ -0,0 +1 @@ |
||||
#define VAL 42 |
@ -0,0 +1,23 @@ |
||||
project('find library and headers', 'c') |
||||
|
||||
cc = meson.get_compiler('c') |
||||
|
||||
if not cc.find_library('z', required : false).found() |
||||
error('MESON_SKIP_TEST: zlib not found.') |
||||
endif |
||||
|
||||
lib = cc.find_library('z', |
||||
has_headers : 'foo.h', |
||||
required : false) |
||||
assert(not lib.found(), 'Header should be missing') |
||||
|
||||
lib = cc.find_library('z', |
||||
has_headers : 'foo.h', |
||||
header_include_directories : include_directories('.')) |
||||
assert(lib.found(), 'Header should be found') |
||||
|
||||
lib = cc.find_library('z', |
||||
has_headers : ['foo.h', 'bar.h'], |
||||
header_include_directories : include_directories('.'), |
||||
required : false) |
||||
assert(not lib.found(), 'One header should be missing') |
Loading…
Reference in new issue