From 025aea1dab4bcf9aafdd72acf48476d999a729b9 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 3 Sep 2023 12:27:47 -0400 Subject: [PATCH] Compiler checks must use per-subproject options Fixes: #12202 --- mesonbuild/interpreter/compiler.py | 2 +- .../223 persubproject options/subprojects/sub2/meson.build | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index b6a1a85f3..5528abe7a 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -261,7 +261,7 @@ class CompilerHolder(ObjectHolder['Compiler']): for idir in i.to_string_list(self.environment.get_source_dir(), self.environment.get_build_dir()): args.extend(self.compiler.get_include_args(idir, False)) if not kwargs['no_builtin_args']: - opts = self.environment.coredata.options + opts = coredata.OptionsView(self.environment.coredata.options, self.subproject) args += self.compiler.get_option_compile_args(opts) if mode is CompileCheckMode.LINK: args.extend(self.compiler.get_option_link_args(opts)) diff --git a/test cases/common/223 persubproject options/subprojects/sub2/meson.build b/test cases/common/223 persubproject options/subprojects/sub2/meson.build index cf1435a4f..88622207d 100644 --- a/test cases/common/223 persubproject options/subprojects/sub2/meson.build +++ b/test cases/common/223 persubproject options/subprojects/sub2/meson.build @@ -14,3 +14,7 @@ shared_library('lib1', 'foo.c') # Parent project is c++11 but this one uses c++14 to build. libcpp14 = library('lib2', 'foo.cpp') meson.override_dependency('libcpp14', declare_dependency(link_with: libcpp14)) + +# Compiler checks should be using c++14 as well +cxx = meson.get_compiler('cpp') +assert(cxx.compiles(files('foo.cpp')))