aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/interpreter.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/cmake/interpreter.py')
-rw-r--r--mesonbuild/cmake/interpreter.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index 125f18b..0a452d1 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -289,7 +289,15 @@ class ConverterTarget:
for j in self.compile_opts[i]:
m = ConverterTarget.std_regex.match(j)
if m:
- self.override_options += ['{}_std={}'.format(i, m.group(2))]
+ std = m.group(2)
+ if std not in self._all_lang_stds(i):
+ mlog.warning(
+ 'Unknown {}_std "{}" -> Ingoring. Try setting the project'
+ 'level {}_std if build errors occur.'.format(i, std),
+ once=True
+ )
+ continue
+ self.override_options += ['{}_std={}'.format(i, std)]
elif j in ['-fPIC', '-fpic', '-fPIE', '-fpie']:
self.pie = True
elif j in blacklist_compiler_flags:
@@ -539,6 +547,13 @@ class ConverterTarget:
suffixes += [x for x in exts]
return suffixes
+ @lru_cache(maxsize=None)
+ def _all_lang_stds(self, lang: str) -> T.List[str]:
+ lang_opts = self.env.coredata.compiler_options.build.get(lang, None)
+ if not lang_opts or 'std' not in lang_opts:
+ return []
+ return lang_opts['std'].choices
+
def process_inter_target_dependencies(self):
# Move the dependencies from all transfer_dependencies_from to the target
to_process = list(self.depends)