diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 7143d9e92d7a..d60ed99e83b8 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -309,6 +309,14 @@ def get_options(self) -> 'MutableKeyedOptionDictType': std_opt.set_versions(cppstd_choices, gnu=True) return opts + def get_option_std_args(self, target: BuildTarget, subproject: T.Optional[str] = None) -> T.List[str]: + args: T.List[str] = [] + std = self.get_compileropt_value('std', target, subproject) + assert isinstance(std, str) + if std != 'none': + args.append('-std=' + std) + return args + class ElbrusCCompiler(ElbrusCompiler, CCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index bdf60f6c23a2..5ed4aea81ee2 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -572,6 +572,14 @@ def get_options(self) -> 'MutableKeyedOptionDictType': std_opt.set_versions(cppstd_choices) return opts + def get_option_std_args(self, target: BuildTarget, subproject: T.Optional[str] = None) -> T.List[str]: + args: T.List[str] = [] + std = self.get_compileropt_value('std', target, subproject) + assert isinstance(std, str) + if std != 'none': + args.append(self._find_best_cpp_std(std)) + return args + class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler): def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,