1project('dep fallback', 'c')
2
3bob = dependency('boblib', fallback : ['boblib', 'bob_dep'], required: false,
4  default_options : 'warning_level=1')
5if not bob.found()
6    error('Bob is actually needed')
7endif
8
9# boblib subproject exists, but bobinc is not a dependency variable
10sita = dependency('sitalib', fallback : ['boblib', 'bobinc'], required: false)
11assert(not sita.found())
12# boblib subproject exists, but sita_dep doesn't exist
13sita = dependency('sitalib', fallback : ['boblib', 'sita_dep'], required: false)
14assert(not sita.found())
15# boblib has been configured so zlib cannot be searched on the system
16zlib = dependency('zlib', fallback : ['boblib', 'notfound_dep'], required: false)
17assert(not zlib.found())
18# boblib has been configured so zlib cannot be searched on the system.
19# Not variable name provided and the subproject does not override zlib.
20zlib = dependency('zlib', fallback : 'boblib', required: false)
21assert(not zlib.found())
22
23# jimmylib subproject doesn't exist
24jimmy = dependency('jimmylib', fallback : ['jimmylib', 'jimmy_dep'], required: false)
25# dummylib subproject fails to configure
26dummy = dependency('dummylib', fallback : ['dummylib', 'dummy_dep'], required: false)
27
28gensrc_py = find_program('gensrc.py')
29gensrc = custom_target('gensrc.c',
30  input : 'tester.c',
31  output : 'gensrc.c',
32  command : [gensrc_py, '@INPUT@', '@OUTPUT@'])
33
34exe = executable('bobtester',
35  [gensrc],
36  dependencies : bob)
37
38test('bobtester', exe)
39