Merge pull request #2581 from NickeZ/check-subproj-version
Disallow subprojects have incompatible depspull/2832/head
commit
d55e98ef50
22 changed files with 158 additions and 6 deletions
@ -0,0 +1,9 @@ |
||||
#include <stdio.h> |
||||
#include "a.h" |
||||
#include "b.h" |
||||
|
||||
int main(int argc, char **argv) { |
||||
int life = a_fun() + b_fun(); |
||||
printf("%d\n", life); |
||||
return 0; |
||||
} |
@ -0,0 +1,9 @@ |
||||
project('super', 'c') |
||||
|
||||
# A will use version 1 of C |
||||
a_dep = dependency('a', fallback: ['a', 'a_dep']) |
||||
|
||||
# B will fail becuase it requests version 2 of C |
||||
b_dep = dependency('b', fallback: ['b', 'b_dep']) |
||||
|
||||
main = executable('main', files('main.c'), dependencies: [a_dep, b_dep]) |
@ -0,0 +1,5 @@ |
||||
#include "c.h" |
||||
|
||||
int a_fun() { |
||||
return c_fun(); |
||||
} |
@ -0,0 +1 @@ |
||||
int a_fun(); |
@ -0,0 +1,11 @@ |
||||
project('a', 'c') |
||||
|
||||
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('.'), |
||||
) |
@ -0,0 +1,5 @@ |
||||
#include "c.h" |
||||
|
||||
int b_fun(){ |
||||
return c_fun(); |
||||
} |
@ -0,0 +1 @@ |
||||
int b_fun(); |
@ -0,0 +1,11 @@ |
||||
project('b', 'c') |
||||
|
||||
c_dep = dependency('c', version:'2', fallback: ['c', 'c_dep']) |
||||
|
||||
blib = library('b', 'b.c', |
||||
dependencies: c_dep) |
||||
|
||||
b_dep = declare_dependency( |
||||
link_with: blib, |
||||
include_directories: include_directories('.'), |
||||
) |
@ -0,0 +1,3 @@ |
||||
static int c_fun(){ |
||||
return 3; |
||||
} |
@ -0,0 +1,5 @@ |
||||
project('c', 'c', version:'1') |
||||
|
||||
c_dep = declare_dependency( |
||||
include_directories: include_directories('.') |
||||
) |
@ -0,0 +1,9 @@ |
||||
#include <stdio.h> |
||||
#include "a.h" |
||||
#include "b.h" |
||||
|
||||
int main(int argc, char **argv) { |
||||
int life = a_fun() + b_fun(); |
||||
printf("%d\n", life); |
||||
return 0; |
||||
} |
@ -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]) |
@ -0,0 +1,5 @@ |
||||
#include "c.h" |
||||
|
||||
int a_fun() { |
||||
return c_fun(); |
||||
} |
@ -0,0 +1 @@ |
||||
int a_fun(); |
@ -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('.'), |
||||
) |
@ -0,0 +1,11 @@ |
||||
#if defined(WITH_C) |
||||
#include "c.h" |
||||
#endif |
||||
|
||||
int b_fun(){ |
||||
#if defined(WITH_C) |
||||
return c_fun(); |
||||
#else |
||||
return 0; |
||||
#endif |
||||
} |
@ -0,0 +1 @@ |
||||
int b_fun(); |
@ -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('.'), |
||||
) |
@ -0,0 +1,3 @@ |
||||
static int c_fun(){ |
||||
return 3; |
||||
} |
@ -0,0 +1,5 @@ |
||||
project('c', 'c', version:'1') |
||||
|
||||
c_dep = declare_dependency( |
||||
include_directories: include_directories('.') |
||||
) |
Loading…
Reference in new issue