From 739341ec045a42892b454f59f76515f73c2a8759 Mon Sep 17 00:00:00 2001 From: Nicolas Schneider Date: Tue, 1 Jan 2019 16:13:27 +0100 Subject: compile pch .h file as c++-header when building a c++ target Fixes #3641. --- mesonbuild/backend/ninjabackend.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mesonbuild/backend/ninjabackend.py') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 5d59fa9..372d7c2 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2184,6 +2184,10 @@ rule FORTRAN_DEP_HACK%s def generate_gcc_pch_command(self, target, compiler, pch): commands = self._generate_single_compile(target, compiler) + if pch.split('.')[-1] == 'h' and compiler.language == 'cpp': + # Explicitly compile pch headers as C++. If Clang is invoked in C++ mode, it actually warns if + # this option is not set, and for gcc it also makes sense to use it. + commands += ['-x', 'c++-header'] dst = os.path.join(self.get_target_private_dir(target), os.path.basename(pch) + '.' + compiler.get_pch_suffix()) dep = dst + '.' + compiler.get_depfile_suffix() -- cgit v1.1