meson: Support auto/true/false for optional dependencies

At the moment, missing optional dependencies will be silently ignored
when the corresponding configuration flag is 'true', and won't be tested
for when the flag is 'false'.
In the autotools build, this corresponds respectively to
--enable-foo=auto and --disable-foo.
Having a way to get an error when the package is enabled but missing is
quite desirable. f52247384 has some half-baked attempt at that, but this
was supposed to be removed from the series. This causes errors when
processing meson.build, breaking the meson build.
This commit adds 'true'/'false'/'auto' in a proper way.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Christophe Fergeau 2018-06-06 12:58:55 +02:00 committed by Frediano Ziglio
parent 1dcdefa8b3
commit e95f05452a
2 changed files with 17 additions and 18 deletions

View File

@ -117,22 +117,19 @@ endforeach
#
# Check deps which are optional but enabled by default. This foreach block only
# checks the option, and adds the package to the deps list, while the real check
# for the dependency is done in the foeach block below.
# for the dependency is done in the foreach block below.
optional_deps = [
['celt051', '>= 0.5.1.1', false, 'HAVE_CELT051'],
['opus', '>= 0.9.14', true, 'HAVE_OPUS'],
['celt051', '>= 0.5.1.1', 'HAVE_CELT051'],
['opus', '>= 0.9.14', 'HAVE_OPUS'],
]
foreach dep : optional_deps
if get_option(dep[0])
deps += [dep]
endif
endforeach
foreach dep : deps
d = dependency(dep[0], required : dep[2], version : dep[1])
if d.found()
spice_common_deps += d
spice_common_config_data.set(dep[3], '1')
option_value = get_option(dep[0])
if option_value != 'false'
d = dependency(dep[0], required: (option_value == 'true'), version : dep[1])
if d.found()
spice_common_deps += d
spice_common_config_data.set(dep[2], '1')
endif
endif
endforeach

View File

@ -11,13 +11,15 @@ option('extra-checks',
description : 'Enable extra checks on code (default=false)')
option('celt051',
type : 'boolean',
value : false,
description: 'Enable celt051 audio codec (default=false)')
type : 'combo',
choices : ['true', 'false', 'auto'],
value : 'auto',
description: 'Enable celt051 audio codec (default=auto)')
option('opus',
type : 'boolean',
value : true,
type : 'combo',
choices : ['true', 'false', 'auto'],
value : 'true',
description: 'Enable Opus audio codec (default=true)')
option('python-checks',