diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index dcf385fb0b45..fe82de942c1d 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -1004,7 +1004,7 @@ def generate_basic_compiler_args(self, target: build.BuildTarget, compiler: 'Com commands += compiler.get_werror_args() # Add compile args for c_* or cpp_* build options set on the # command-line or default_options inside project(). - commands += compiler.get_option_compile_args(target, self.environment) + commands += compiler.get_option_compile_args(target, self.environment, target.subproject) optimization = self.get_target_option(target, 'optimization') assert isinstance(optimization, str), 'for mypy' @@ -2077,10 +2077,12 @@ def is_unity(self, target: build.BuildTarget) -> bool: def get_target_option(self, target: build.Target, name: T.Union[str, OptionKey]) -> T.Union[str, int, bool, 'WrapMode']: if isinstance(name, str): - key = OptionKey(name) + key = OptionKey(name, subproject=target.subproject) elif isinstance(name, OptionKey): key = name else: import sys sys.exit('Internal error: invalid option type.') + if key.name == 'std': + pass return self.environment.coredata.get_option_for_target(target, key) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 387972e09e62..db3e0c7481a3 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1081,7 +1081,10 @@ def should_use_dyndeps_for_target(self, target: 'build.BuildTarget') -> bool: cpp = target.compilers['cpp'] if cpp.get_id() != 'msvc': return False - cppversion = self.get_target_option(target, OptionKey('std', machine=target.for_machine, lang='cpp')) + cppversion = self.get_target_option(target, OptionKey('std', + machine=target.for_machine, + lang='cpp', + subproject=target.subproject)) if cppversion not in ('latest', 'c++latest', 'vc++latest'): return False if not mesonlib.current_vs_supports_modules(): diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index b8cf66e6620b..10f127803fd4 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -480,6 +480,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType': def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', subproject=None) -> T.List[str]: args = [] key = OptionKey('std', machine=self.for_machine, lang=self.language) + if subproject is not None: + key = key.evolve(subproject=subproject) std = env.determine_option_value(key, target, subproject) rtti = env.determine_option_value(key.evolve('rtti'), target, subproject) debugstl = env.determine_option_value(key.evolve('debugstl'), target, subproject)