diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/linuxlike/12 subprojects in subprojects | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/linuxlike/12 subprojects in subprojects')
10 files changed, 72 insertions, 0 deletions
diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/main.c b/meson/test cases/linuxlike/12 subprojects in subprojects/main.c new file mode 100644 index 000000000..74523173d --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> +#include "a.h" +#include "b.h" + +int main(void) { + int life = a_fun() + b_fun(); + printf("%d\n", life); + return 0; +} diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/meson.build b/meson/test cases/linuxlike/12 subprojects in subprojects/meson.build new file mode 100644 index 000000000..40141494e --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/meson.build @@ -0,0 +1,9 @@ +project('super', 'c') + +# A will use version 1 of C +a_dep = dependency('a', fallback: ['a', 'a_dep']) + +# B has an optional dependency on C version 2 and will therefore work +b_dep = dependency('b', fallback: ['b', 'b_dep']) + +main = executable('main', files('main.c'), dependencies: [a_dep, b_dep]) diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/a.c b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/a.c new file mode 100644 index 000000000..f7dd126fe --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/a.c @@ -0,0 +1,5 @@ +#include "c.h" + +int a_fun(void) { + return c_fun(); +} diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/a.h b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/a.h new file mode 100644 index 000000000..9de0deb2c --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/a.h @@ -0,0 +1 @@ +int a_fun(void); diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/meson.build b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/meson.build new file mode 100644 index 000000000..5f579a372 --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/a/meson.build @@ -0,0 +1,11 @@ +project('a', 'c', version:'1.0') + +c_dep = dependency('c', version:'1', fallback: ['c', 'c_dep']) + +alib = library('a', 'a.c', + dependencies: c_dep) + +a_dep = declare_dependency( + link_with: alib, + include_directories: include_directories('.'), +) diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/b.c b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/b.c new file mode 100644 index 000000000..45c9348f7 --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/b.c @@ -0,0 +1,11 @@ +#if defined(WITH_C) +#include "c.h" +#endif + +int b_fun(void){ +#if defined(WITH_C) +return c_fun(); +#else +return 0; +#endif +} diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/b.h b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/b.h new file mode 100644 index 000000000..47b84d412 --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/b.h @@ -0,0 +1 @@ +int b_fun(void); diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/meson.build b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/meson.build new file mode 100644 index 000000000..80903f3b1 --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/b/meson.build @@ -0,0 +1,17 @@ +project('b', 'c') + +c_dep = dependency('c', version:'2', fallback: ['c', 'c_dep'], required: false) + +assert(c_dep.found() == false, 'C project has the wrong version and should not be found') + +if c_dep.found() + add_global_arguments('-DWITH_C', language: 'c') +endif + +blib = library('b', 'b.c', + dependencies: c_dep) + +b_dep = declare_dependency( + link_with: blib, + include_directories: include_directories('.'), +) diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/c/c.h b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/c/c.h new file mode 100644 index 000000000..b2e3f9b21 --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/c/c.h @@ -0,0 +1,3 @@ +static int c_fun(void){ + return 3; +} diff --git a/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/c/meson.build b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/c/meson.build new file mode 100644 index 000000000..7184933b2 --- /dev/null +++ b/meson/test cases/linuxlike/12 subprojects in subprojects/subprojects/c/meson.build @@ -0,0 +1,5 @@ +project('c', 'c', version:'1') + +c_dep = declare_dependency( + include_directories: include_directories('.') +) |