Compare commits
9 Commits
79d530e325
...
e9bd7d49bd
Author | SHA1 | Date |
---|---|---|
Jussi Pakkanen | e9bd7d49bd | 5 years ago |
Federico Mena Quintero | 60f34a1f51 | 5 years ago |
Dylan Baker | 27b6c62ffd | 5 years ago |
Dylan Baker | 4f347ef14a | 5 years ago |
Dylan Baker | c890c947fa | 5 years ago |
Dylan Baker | ffe2a678d5 | 5 years ago |
Dylan Baker | 53c8852f47 | 5 years ago |
Dylan Baker | d770f1c815 | 5 years ago |
Dylan Baker | c81804e5f2 | 5 years ago |
7 changed files with 179 additions and 2 deletions
@ -0,0 +1,17 @@ |
||||
## Dependency objects now have a get_variable method |
||||
|
||||
This is a generic replacement for type specific variable getters such as |
||||
`ConfigToolDependency.get_configtool_variable` and |
||||
`PkgConfigDependency.get_pkgconfig_variable`, and is the only way to query |
||||
such variables from cmake dependencies. |
||||
|
||||
This method allows you to get variables without knowing the kind of |
||||
dependency you have. |
||||
|
||||
```meson |
||||
dep = dependency('could_be_cmake_or_pkgconfig') |
||||
# cmake returns 'YES', pkg-config returns 'ON' |
||||
if ['YES', 'ON'].contains(dep.get_variable(pkg-config : 'var-name', cmake : 'COP_VAR_NAME', default_value : 'NO')) |
||||
error('Cannot build your project when dep is built with var-name support') |
||||
endif |
||||
``` |
@ -0,0 +1,52 @@ |
||||
project( |
||||
'dependency get_variable', |
||||
['c', 'cpp'], |
||||
) |
||||
|
||||
# Just some string that nothing should return |
||||
default = 'asufoiqwjtl;adjfbpiuqwoehtl;ajdfl;ghal;sdjg' |
||||
|
||||
dep = dependency('zlib', method: 'pkg-config', required : false) |
||||
if not dep.found() |
||||
warning('Skipping pkg-config tests as zlib is not avialable or is not pkg-config') |
||||
else |
||||
# Test for regular pkg-config |
||||
# We don't know what the value will be, but we know it should be the same |
||||
dep = dependency('zlib', method : 'pkg-config') |
||||
assert(dep.get_pkgconfig_variable('prefix') == dep.get_variable(pkgconfig : 'prefix'), |
||||
'Got different values from get_pkgconfig_variable and get_variable(pkgconfig: )') |
||||
assert(dep.get_variable(pkgconfig : default, default_value : default) == default, |
||||
'pkg-config didnt get default when we should have.') |
||||
assert(dep.get_variable(pkgconfig : 'prefix', default_value : default) != default, |
||||
'pkg-config got default when we shouldnt have.') |
||||
endif |
||||
|
||||
dep_ct = dependency('llvm', method : 'config-tool', required : false) |
||||
if not dep_ct.found() |
||||
warning('Skipping config-tool tests as llvm is not available or llvm-config was not found.') |
||||
else |
||||
assert(dep_ct.get_configtool_variable('has-rtti') == dep_ct.get_variable(configtool : 'has-rtti'), |
||||
'Got different values from get_configtool_variable and get_variable(configtool: )') |
||||
assert(dep_ct.get_variable(configtool : default, default_value : default) == default, |
||||
'config-tool didnt get default when we should have.') |
||||
assert(dep_ct.get_variable(configtool : 'has-rtti', default_value : default) != default, |
||||
'config-tool got default when we shouldnt have.') |
||||
endif |
||||
|
||||
dep_cm = dependency('llvm', method : 'cmake', required : false) |
||||
if not dep_cm.found() |
||||
warning('Skipping cmake tests as llvm is not available via the cmake finder.') |
||||
else |
||||
if dep_ct.found() |
||||
assert((dep_cm.get_variable(cmake : 'LLVM_ENABLE_RTTI') == 'ON') == (dep_ct.get_variable(configtool : 'has-rtti') == 'YES'), |
||||
'RTTI information for cmake and config tools disagree') |
||||
endif |
||||
assert(dep_cm.get_variable(cmake : default, default_value : default) == default, |
||||
'cmake didnt get default when we should have.') |
||||
assert(dep_cm.get_variable(cmake : 'LLVM_ENABLE_RTTI', default_value : default) != default, |
||||
'cmake config-tool got default when we shouldnt have.') |
||||
endif |
||||
|
||||
idep = declare_dependency() |
||||
assert(idep.get_variable(pkgconfig : 'foo', cmake : 'foo', configtool : 'foo', default_value : default) == default, |
||||
'Got something other than default from an internal dependency') |
Loading…
Reference in new issue