modules/cmake: Add a found() method to the cmake subproject
Just like the native meson subproject has.
This commit is contained in:
parent
52d36aaec1
commit
73ddc01477
|
@ -99,6 +99,8 @@ and supports the following methods:
|
|||
- `get_variable(name)` fetches the specified variable from inside
|
||||
the subproject. Usually `dependency()` or `target()` should be
|
||||
preferred to extract build targets.
|
||||
- `found` returns true if the subproject is available, otherwise false
|
||||
*new in in 0.53.2*
|
||||
|
||||
## CMake configuration files
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class CMakeSubprojectHolder(InterpreterObject, ObjectHolder):
|
|||
'target': self.target,
|
||||
'target_type': self.target_type,
|
||||
'target_list': self.target_list,
|
||||
'found': self.found_method,
|
||||
})
|
||||
|
||||
def _args_to_info(self, args):
|
||||
|
@ -110,6 +111,13 @@ class CMakeSubprojectHolder(InterpreterObject, ObjectHolder):
|
|||
def target_list(self, args, kwargs):
|
||||
return self.held_object.cm_interpreter.target_list()
|
||||
|
||||
@noPosargs
|
||||
@permittedKwargs({})
|
||||
@FeatureNew('CMakeSubproject.found()', '0.53.2')
|
||||
def found_method(self, args, kwargs):
|
||||
return self.held_object is not None
|
||||
|
||||
|
||||
class CmakeModule(ExtensionModule):
|
||||
cmake_detected = False
|
||||
cmake_root = None
|
||||
|
|
|
@ -5,6 +5,7 @@ cm = import('cmake')
|
|||
sub_pro = cm.subproject('cmMod')
|
||||
sub_dep = sub_pro.dependency('cmModLib++')
|
||||
|
||||
assert(sub_pro.found(), 'found() method reports not found, but should be found')
|
||||
assert(sub_pro.target_list() == ['cmModLib++'], 'There should be exactly one target')
|
||||
assert(sub_pro.target_type('cmModLib++') == 'shared_library', 'Target type should be shared_library')
|
||||
|
||||
|
|
|
@ -2,4 +2,5 @@ project('cmakeSubTest', ['c', 'cpp'])
|
|||
|
||||
cm = import('cmake')
|
||||
|
||||
sub_pro = cm.subproject('nothinig', required: false)
|
||||
sub_pro = cm.subproject('nothinig', required: false)
|
||||
assert(not sub_pro.found(), 'subproject found() reports wrong value')
|
||||
|
|
Loading…
Reference in New Issue