summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/coredata.py7
-rw-r--r--unittests/allplatformstests.py2
-rw-r--r--unittests/platformagnostictests.py7
3 files changed, 14 insertions, 2 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index b2b966b7d..e7de3d7fd 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -974,6 +974,8 @@ class CoreData:
return dirty
def set_default_options(self, default_options: T.MutableMapping[OptionKey, str], subproject: str, env: 'Environment') -> None:
+ from .compilers import base_options
+
# Main project can set default options on subprojects, but subprojects
# can only set default options on themselves.
# Preserve order: if env.options has 'buildtype' it must come after
@@ -1005,7 +1007,10 @@ class CoreData:
continue
# Skip base, compiler, and backend options, they are handled when
# adding languages and setting backend.
- if k.type in {OptionType.COMPILER, OptionType.BACKEND, OptionType.BASE}:
+ if k.type in {OptionType.COMPILER, OptionType.BACKEND}:
+ continue
+ if k.type == OptionType.BASE and k in base_options:
+ # set_options will report unknown base options
continue
options[k] = v
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 777f2f92a..1064e6adb 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -2694,7 +2694,7 @@ class AllPlatformTests(BasePlatformTests):
# It is not an error to set wrong option for unknown subprojects or
# language because we don't have control on which one will be selected.
- self.init(testdir, extra_args=['-Dc_wrong=1', '-Dwrong:bad=1', '-Db_wrong=1'])
+ self.init(testdir, extra_args=['-Dc_wrong=1', '-Dwrong:bad=1'])
self.wipe()
# Test we can set subproject option
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index 6884da42e..21cb3b945 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -285,3 +285,10 @@ class PlatformAgnosticTests(BasePlatformTests):
out = self.init(testdir, extra_args=['--reconfigure', '-Db_ndebug=if-release', '-Dc_std=c99'])
self.assertIn('\nMessage: b_ndebug: if-release\n', out)
self.assertIn('\nMessage: c_std: c99\n', out)
+
+ def test_setup_with_unknown_option(self):
+ testdir = os.path.join(self.common_test_dir, '1 trivial')
+
+ for option in ('not_an_option', 'b_not_an_option'):
+ out = self.init(testdir, extra_args=['--wipe', f'-D{option}=1'], allow_fail=True)
+ self.assertIn(f'ERROR: Unknown options: "{option}"', out)