Feature option object (feature
)
Meson object representing a feature
options
Returned by
Feature option object objects are returned by the following functions and methods:
Feature option object methods
feature.allowed()
Returns whether the feature was set to 'enabled'
or 'auto'
Signature
(since 0.59.0)
bool allowed()
feature.auto()
Returns whether the feature was set to 'auto'
Signature
bool auto()
feature.disable_auto_if()
Returns the feature, with 'auto'
converted to 'disabled'
if value is true.
Feature / Condition | value = true
|
value = false
|
---|---|---|
Enabled | Enabled | Enabled |
Disabled | Disabled | Disabled |
Auto | Disabled | Auto |
Signature
(since 0.59.0)
# Returns the feature, with `'auto'` converted to `'disabled'` if value is true
feature disable_auto_if(
bool value, # See the table above
)
Arguments
The method feature.disable_auto_if()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
value |
bool |
See the table above |
|
feature.disabled()
Returns whether the feature was set to 'disabled'
Signature
bool disabled()
feature.enabled()
Returns whether the feature was set to 'enabled'
Signature
bool enabled()
feature.require()
Returns the object itself if the value is true; an error if the object is
'enabled'
and the value is false; a disabled feature if the object
is 'auto'
or 'disabled'
and the value is false.
Signature
(since 0.59.0)
# Returns the object itself if the value is true; an error if the object is
feature require(
bool value, # The value to check
# Keyword arguments:
error_message : str # The error Message to print if the check fails
)
Example
require
is useful to restrict the applicability of 'auto'
features,
for example based on other features or on properties of the host machine:
if get_option('directx').require(host_machine.system() == 'windows',
error_message: 'DirectX only available on Windows').allowed() then
src += ['directx.c']
config.set10('HAVE_DIRECTX', 1)
endif
Arguments
The method feature.require()
accepts the following positional arguments:
Name | Type | Description | Tags |
---|---|---|---|
value |
bool |
The value to check |
|
Finally, feature.require()
accepts the following keyword arguments:
Name | Type | Description | Tags |
---|---|---|---|
error_message |
str |
The error Message to print if the check fails |
|
The results of the search are