diff options
Diffstat (limited to 'meson/test cases/common/230 external project')
9 files changed, 126 insertions, 0 deletions
diff --git a/meson/test cases/common/230 external project/app.c b/meson/test cases/common/230 external project/app.c new file mode 100644 index 000000000..166f00737 --- /dev/null +++ b/meson/test cases/common/230 external project/app.c @@ -0,0 +1,7 @@ +#include <libfoo.h> + +int main(void) +{ + return call_foo() == 42 ? 0 : 1; +} + diff --git a/meson/test cases/common/230 external project/func.c b/meson/test cases/common/230 external project/func.c new file mode 100644 index 000000000..5e8f933f5 --- /dev/null +++ b/meson/test cases/common/230 external project/func.c @@ -0,0 +1,7 @@ +#include "func.h" + +int func(void) +{ + return 1; +} + diff --git a/meson/test cases/common/230 external project/func.h b/meson/test cases/common/230 external project/func.h new file mode 100644 index 000000000..340b82ac8 --- /dev/null +++ b/meson/test cases/common/230 external project/func.h @@ -0,0 +1 @@ +int func(void); diff --git a/meson/test cases/common/230 external project/libfoo/configure b/meson/test cases/common/230 external project/libfoo/configure new file mode 100755 index 000000000..0e4aa72b2 --- /dev/null +++ b/meson/test cases/common/230 external project/libfoo/configure @@ -0,0 +1,44 @@ +#! /bin/sh + +srcdir=$(dirname "$0") + +for i in "$@" +do +case $i in + --prefix=*) + PREFIX="${i#*=}" + shift + ;; + --libdir=*) + LIBDIR="${i#*=}" + shift + ;; + --includedir=*) + INCDIR="${i#*=}" + shift + ;; + --libext=*) + LIBEXT="${i#*=}" + shift + ;; + *) + shift + ;; +esac +done + +DEP_ARGS=$(pkg-config --cflags --libs somelib) + +cat > Makefile << EOL +all: libfoo.$LIBEXT + +libfoo.$LIBEXT: + $CC "$srcdir/libfoo.c" -shared -fPIC $DEP_ARGS -o \$@ + +install: libfoo.$LIBEXT + mkdir -p "\$(DESTDIR)$LIBDIR"; + mkdir -p "\$(DESTDIR)$LIBDIR/pkgconfig"; + mkdir -p "\$(DESTDIR)$INCDIR"; + cp \$< "\$(DESTDIR)$LIBDIR"; + cp "$srcdir/libfoo.h" "\$(DESTDIR)$INCDIR"; +EOL diff --git a/meson/test cases/common/230 external project/libfoo/libfoo.c b/meson/test cases/common/230 external project/libfoo/libfoo.c new file mode 100644 index 000000000..3f6228243 --- /dev/null +++ b/meson/test cases/common/230 external project/libfoo/libfoo.c @@ -0,0 +1,8 @@ +#include "libfoo.h" + +int func(void); + +int call_foo() +{ + return func() == 1 ? 42 : 0; +} diff --git a/meson/test cases/common/230 external project/libfoo/libfoo.h b/meson/test cases/common/230 external project/libfoo/libfoo.h new file mode 100644 index 000000000..8981f18b4 --- /dev/null +++ b/meson/test cases/common/230 external project/libfoo/libfoo.h @@ -0,0 +1,3 @@ +#pragma once + +int call_foo(void); diff --git a/meson/test cases/common/230 external project/libfoo/meson.build b/meson/test cases/common/230 external project/libfoo/meson.build new file mode 100644 index 000000000..941e13f94 --- /dev/null +++ b/meson/test cases/common/230 external project/libfoo/meson.build @@ -0,0 +1,22 @@ +mod = import('unstable_external_project') + +target_system = target_machine.system() +if target_system in ['windows', 'cygwin'] + libext = 'dll' +elif target_system == 'darwin' + libext = 'dylib' +else + libext = 'so' +endif + +p = mod.add_project('configure', + configure_options : [ + '--prefix=@PREFIX@', + '--libdir=@PREFIX@/@LIBDIR@', + '--includedir=@PREFIX@/@INCLUDEDIR@', + '--libext=' + libext, + ], +) + +libfoo_dep = declare_dependency(link_with : somelib, + dependencies : p.dependency('foo')) diff --git a/meson/test cases/common/230 external project/meson.build b/meson/test cases/common/230 external project/meson.build new file mode 100644 index 000000000..d1ed797c4 --- /dev/null +++ b/meson/test cases/common/230 external project/meson.build @@ -0,0 +1,27 @@ +project('test external project', 'c') + +if not find_program('pkg-config', required: false).found() + error('MESON_SKIP_TEST: pkg-config not found') +endif + +if not find_program('make', required : false).found() + error('MESON_SKIP_TEST: make not found') +endif + +if host_machine.system() == 'windows' + error('MESON_SKIP_TEST: The fake configure script is too dumb to work on Windows') +endif + +if meson.is_cross_build() + # CI uses PKG_CONFIG_SYSROOT_DIR which breaks -uninstalled.pc usage. + error('MESON_SKIP_TEST: Cross build support is too limited for this test') +endif + +pkg = import('pkgconfig') + +somelib = library('somelib', 'func.c') +pkg.generate(somelib) + +subdir('libfoo') + +executable('test-find-library', 'app.c', dependencies : libfoo_dep) diff --git a/meson/test cases/common/230 external project/test.json b/meson/test cases/common/230 external project/test.json new file mode 100644 index 000000000..4888e8752 --- /dev/null +++ b/meson/test cases/common/230 external project/test.json @@ -0,0 +1,7 @@ +{ + "installed": [ + { "type": "shared_lib", "file": "usr/lib/foo" }, + { "type": "file", "file": "usr/include/libfoo.h" }, + { "type": "file", "file": "usr/lib/pkgconfig/somelib.pc" } + ] +} |