include_type: Add CMake subporject dependency method (fixes #6879)
This commit is contained in:
parent
e00df9046d
commit
e36f713a7f
|
@ -133,7 +133,10 @@ kept for compatibility. It will not work together with the `options` kwarg.
|
||||||
This object is returned by the `subproject` function described above
|
This object is returned by the `subproject` function described above
|
||||||
and supports the following methods:
|
and supports the following methods:
|
||||||
|
|
||||||
- `dependency(target)` returns a dependency object for any CMake target.
|
- `dependency(target)` returns a dependency object for any CMake target. The
|
||||||
|
`include_type` kwarg *(new in 0.56.0)* controls the include type of the
|
||||||
|
returned dependency object similar to the same kwarg in the
|
||||||
|
[`dependency()`](Reference-manual.md#dependency) function.
|
||||||
- `include_directories(target)` returns a meson `include_directories()`
|
- `include_directories(target)` returns a meson `include_directories()`
|
||||||
object for the specified target. Using this function is not necessary
|
object for the specified target. Using this function is not necessary
|
||||||
if the dependency object is used.
|
if the dependency object is used.
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
## `include_type` support for the CMake subproject object dependency method
|
||||||
|
|
||||||
|
The `dependency()` method of the CMake subproject object now also supports the
|
||||||
|
`include_type` kwarg which is similar to the sane kwarg in the `dependency()`
|
||||||
|
function.
|
|
@ -20,7 +20,7 @@ from . import ExtensionModule, ModuleReturnValue
|
||||||
|
|
||||||
from .. import build, dependencies, mesonlib, mlog
|
from .. import build, dependencies, mesonlib, mlog
|
||||||
from ..cmake import SingleTargetOptions, TargetOptions, cmake_defines_to_args
|
from ..cmake import SingleTargetOptions, TargetOptions, cmake_defines_to_args
|
||||||
from ..interpreter import ConfigurationDataHolder, InterpreterException, SubprojectHolder
|
from ..interpreter import ConfigurationDataHolder, InterpreterException, SubprojectHolder, DependencyHolder
|
||||||
from ..interpreterbase import (
|
from ..interpreterbase import (
|
||||||
InterpreterObject,
|
InterpreterObject,
|
||||||
ObjectHolder,
|
ObjectHolder,
|
||||||
|
@ -105,11 +105,18 @@ class CMakeSubprojectHolder(InterpreterObject, ObjectHolder):
|
||||||
def get_variable(self, args, kwargs):
|
def get_variable(self, args, kwargs):
|
||||||
return self.held_object.get_variable_method(args, kwargs)
|
return self.held_object.get_variable_method(args, kwargs)
|
||||||
|
|
||||||
@noKwargs
|
@FeatureNewKwargs('dependency', '0.56.0', ['include_type'])
|
||||||
|
@permittedKwargs({'include_type'})
|
||||||
@stringArgs
|
@stringArgs
|
||||||
def dependency(self, args, kwargs):
|
def dependency(self, args, kwargs):
|
||||||
info = self._args_to_info(args)
|
info = self._args_to_info(args)
|
||||||
return self.get_variable([info['dep']], kwargs)
|
orig = self.get_variable([info['dep']], {})
|
||||||
|
assert isinstance(orig, DependencyHolder)
|
||||||
|
actual = orig.include_type_method([], {})
|
||||||
|
if 'include_type' in kwargs and kwargs['include_type'] != actual:
|
||||||
|
mlog.debug('Current include type is {}. Converting to requested {}'.format(actual, kwargs['include_type']))
|
||||||
|
return orig.as_system_method([kwargs['include_type']], {})
|
||||||
|
return orig
|
||||||
|
|
||||||
@noKwargs
|
@noKwargs
|
||||||
@stringArgs
|
@stringArgs
|
||||||
|
|
|
@ -3,11 +3,12 @@ project('cmakeSubTest', ['c', 'cpp'])
|
||||||
cm = import('cmake')
|
cm = import('cmake')
|
||||||
|
|
||||||
sub_pro = cm.subproject('cmMod')
|
sub_pro = cm.subproject('cmMod')
|
||||||
sub_dep = sub_pro.dependency('cmModLib++')
|
sub_dep = sub_pro.dependency('cmModLib++', include_type: 'system')
|
||||||
|
|
||||||
assert(sub_pro.found(), 'found() method reports not found, but should be found')
|
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_list() == ['cmModLib++'], 'There should be exactly one target')
|
||||||
assert(sub_pro.target_type('cmModLib++') == 'shared_library', 'Target type should be shared_library')
|
assert(sub_pro.target_type('cmModLib++') == 'shared_library', 'Target type should be shared_library')
|
||||||
|
assert(sub_dep.include_type() == 'system', 'the include_type kwarg of dependency() works')
|
||||||
|
|
||||||
exe1 = executable('main', ['main.cpp'], dependencies: [sub_dep])
|
exe1 = executable('main', ['main.cpp'], dependencies: [sub_dep])
|
||||||
test('test1', exe1)
|
test('test1', exe1)
|
||||||
|
|
Loading…
Reference in New Issue