meson: Subproject default_options are ignored
Describe the bug
The ‘default_options’ argument to ‘subproject()’ seems to be ignored.
To Reproduce
Main meson.build
:
...
libfoo = subproject('libfoo', default_options: [ 'BUILD_TESTS=false' ])
...
Libfoo meson.build
:
...
if get_option('BUILD_TESTS')
message('Building unit tests')
subdir('tests')
endif
...
Libfoo meson_options.txt
:
option('BUILD_TESTS', type: 'boolean', value: true)
Then:
rm -rf ./build
meson ./build
Tests are built, the default_options
setting is ignored. meson configure
shows ‘libfoo:BUILD_TESTS = true’.
To achieve desired behaviour, the option has to be specified from the command line:
rm -rf ./build
meson ./build -D libfoo:BUILD_TESTS=false
Expected behavior
Don’t ignore subproject()
default_options
.
system parameters
- Plain native build
- Oracle Linux 7.7
- Python version: 3.7.4
- Meson version: 0.53.1
- Ninja version: 1.9.0
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 15 (9 by maintainers)
Commits related to this issue
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
- meson: add default_options for labwc These are normally set in labwc's meson.build, but for some reason that isn't working correctly with subproject(). Possibly related: https://github.com/mesonbuil... — committed to jlindgren90/wlroots by jlindgren90 9 months ago
This seems to be a long-standing issue. As a workaround you can put all default options for your subprojects in the superproject’s
project()
statement, like so: