diff options
Diffstat (limited to 'test cases/linuxlike/1 pkg-config')
-rw-r--r-- | test cases/linuxlike/1 pkg-config/incdir/myinc.h | 3 | ||||
-rw-r--r-- | test cases/linuxlike/1 pkg-config/meson.build | 53 | ||||
-rw-r--r-- | test cases/linuxlike/1 pkg-config/prog-checkver.c | 15 | ||||
-rw-r--r-- | test cases/linuxlike/1 pkg-config/prog.c | 8 |
4 files changed, 79 insertions, 0 deletions
diff --git a/test cases/linuxlike/1 pkg-config/incdir/myinc.h b/test cases/linuxlike/1 pkg-config/incdir/myinc.h new file mode 100644 index 0000000..4b66a6c --- /dev/null +++ b/test cases/linuxlike/1 pkg-config/incdir/myinc.h @@ -0,0 +1,3 @@ +#pragma once + +#include<zlib.h> diff --git a/test cases/linuxlike/1 pkg-config/meson.build b/test cases/linuxlike/1 pkg-config/meson.build new file mode 100644 index 0000000..ca48e9b --- /dev/null +++ b/test cases/linuxlike/1 pkg-config/meson.build @@ -0,0 +1,53 @@ +project('external dependency', 'c') + +# Zlib is probably on all dev machines. + +dep = dependency('zlib', version : '>=1.2', + not_found_message: 'DANGER! DANGER! THIS MUST NEVER BE SEEN!') +exe = executable('zlibprog', 'prog-checkver.c', + dependencies : dep, + c_args : '-DFOUND_ZLIB="' + dep.version() + '"') + +assert(dep.version().version_compare('>=1.2'), 'Pkg-config version numbers exposed incorrectly.') + +# Check that the version exposed by zlib internally is the same as the one we +# retrieve from the pkg-config file. This assumes that the packager didn't mess +# up, but we can be reasonably sure of that. +test('zlibtest', exe) + +zprefix = dep.get_pkgconfig_variable('prefix') # Always set but we can't be sure what the value is. +# pkg-config returns empty string for not defined variables +assert(dep.get_pkgconfig_variable('nonexisting') == '', 'Value of unknown variable is not empty.') +# ... unless default: is used +assert(dep.get_pkgconfig_variable('nonexisting', default: 'foo') == 'foo', 'Value of unknown variable is not defaulted.') +# pkg-config is able to replace variables +assert(dep.get_pkgconfig_variable('prefix', define_variable: ['prefix', '/tmp']) == '/tmp', 'prefix variable has not been replaced.') + +# Test that dependencies of dependencies work. +dep2 = declare_dependency(dependencies : dep) +exe2 = executable('zlibprog2', 'prog.c', dependencies : dep2) +test('zlibtest2', exe2) + +# Try to find a nonexistent library to ensure requires:false works. + +dep = dependency('nvakuhrabnsdfasdf', required : false, + not_found_message : 'This dependency was not found as was expected.') + +# Try to compile a test that takes a dep and an include_directories + +cc = meson.get_compiler('c') +zlibdep = cc.find_library('z') +code = '''#include<myinc.h> + +int main(void) { + void * something = deflate; + if(something != 0) + return 0; + return 1; +} +''' + +inc = include_directories('incdir') + +r = cc.run(code, include_directories : inc, dependencies : zlibdep) +assert(r.returncode() == 0, 'Running manual zlib test failed.') diff --git a/test cases/linuxlike/1 pkg-config/prog-checkver.c b/test cases/linuxlike/1 pkg-config/prog-checkver.c new file mode 100644 index 0000000..ea1ed32 --- /dev/null +++ b/test cases/linuxlike/1 pkg-config/prog-checkver.c @@ -0,0 +1,15 @@ +#include <zlib.h> +#include <stdio.h> +#include <string.h> + +int main(void) { + void * something = deflate; + if(strcmp(ZLIB_VERSION, FOUND_ZLIB) != 0) { + printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); + return 2; + } + if(something != 0) + return 0; + printf("Couldn't find 'deflate'\n"); + return 1; +} diff --git a/test cases/linuxlike/1 pkg-config/prog.c b/test cases/linuxlike/1 pkg-config/prog.c new file mode 100644 index 0000000..eccc477 --- /dev/null +++ b/test cases/linuxlike/1 pkg-config/prog.c @@ -0,0 +1,8 @@ +#include<zlib.h> + +int main(void) { + void * something = deflate; + if(something != 0) + return 0; + return 1; +} |