| 1 |
project( |
| 2 |
'dependency get_variable', |
| 3 |
['c', 'cpp'], |
| 4 |
) |
| 5 |
|
| 6 |
# Just some string that nothing should return |
| 7 |
default = 'asufoiqwjtl;adjfbpiuqwoehtl;ajdfl;ghal;sdjg' |
| 8 |
|
| 9 |
dep = dependency('zlib', method: 'pkg-config', required : false) |
| 10 |
if not dep.found() |
| 11 |
warning('Skipping pkg-config tests as zlib is not available or is not pkg-config') |
| 12 |
else |
| 13 |
# Test for regular pkg-config |
| 14 |
# We don't know what the value will be, but we know it should be the same |
| 15 |
dep = dependency('zlib', method : 'pkg-config') |
| 16 |
assert(dep.get_pkgconfig_variable('prefix') == dep.get_variable(pkgconfig : 'prefix'), |
| 17 |
'Got different values from get_pkgconfig_variable and get_variable(pkgconfig: )') |
| 18 |
assert(dep.get_variable(pkgconfig : default, default_value : default) == default, |
| 19 |
'pkg-config didn\'t get default when we should have.') |
| 20 |
assert(dep.get_variable(pkgconfig : 'prefix', default_value : default) != default, |
| 21 |
'pkg-config got default when we shouldn\'t have.') |
| 22 |
assert(dep.get_variable(pkgconfig : 'pkgvarnotfound', default_value : '') == '') |
| 23 |
endif |
| 24 |
|
| 25 |
dep_ct = dependency('llvm', method : 'config-tool', required : false) |
| 26 |
if not dep_ct.found() |
| 27 |
warning('Skipping config-tool tests as llvm is not available or llvm-config was not found.') |
| 28 |
else |
| 29 |
assert(dep_ct.get_configtool_variable('has-rtti') == dep_ct.get_variable(configtool : 'has-rtti'), |
| 30 |
'Got different values from get_configtool_variable and get_variable(configtool: )') |
| 31 |
assert(dep_ct.get_variable(configtool : default, default_value : default) == default, |
| 32 |
'config-tool didn\'t get default when we should have.') |
| 33 |
assert(dep_ct.get_variable(configtool : 'has-rtti', default_value : default) != default, |
| 34 |
'config-tool got default when we shouldn\'t have.') |
| 35 |
endif |
| 36 |
|
| 37 |
dep_cm = dependency('llvm', method : 'cmake', required : false) |
| 38 |
if not dep_cm.found() |
| 39 |
warning('Skipping cmake tests as llvm is not available via the cmake finder.') |
| 40 |
else |
| 41 |
if dep_ct.found() |
| 42 |
assert((dep_cm.get_variable(cmake : 'LLVM_ENABLE_RTTI') == 'ON') == (dep_ct.get_variable(configtool : 'has-rtti') == 'YES'), |
| 43 |
'RTTI information for cmake and config tools disagree') |
| 44 |
endif |
| 45 |
assert(dep_cm.get_variable(cmake : default, default_value : default) == default, |
| 46 |
'cmake didn\'t get default when we should have.') |
| 47 |
assert(dep_cm.get_variable(cmake : 'LLVM_ENABLE_RTTI', default_value : default) != default, |
| 48 |
'cmake config-tool got default when we shouldn\'t have.') |
| 49 |
endif |
| 50 |
|
| 51 |
idep = declare_dependency(variables : {'foo' : 'value'}) |
| 52 |
assert(idep.get_variable(pkgconfig : 'foo', cmake : 'foo', configtool : 'foo', |
| 53 |
internal : 'foo', default_value : default) == 'value', |
| 54 |
'internal got default when it shouldn\'t have.') |
| 55 |
assert(idep.get_variable(pkgconfig : 'foo', cmake : 'foo', configtool : 'foo', |
| 56 |
internal : 'bar', default_value : default) == default, |
| 57 |
'internal didn\'t default when it should have.') |
| 58 |
|
| 59 |
idep = declare_dependency() |
| 60 |
assert(idep.get_variable(pkgconfig : 'foo', cmake : 'foo', configtool : 'foo', |
| 61 |
default_value : default) == default, |
| 62 |
'something went wrong with an InternalDependency with no variables.') |
| 63 |
|
| 64 |
idep = declare_dependency(variables : ['foo=value']) |
| 65 |
assert(idep.get_variable(internal: 'foo') == 'value') |
| 66 |
assert(idep.get_variable('foo') == 'value') |
| 67 |
assert(idep.get_variable('invalid', internal: 'foo') == 'value') |