diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-02-16 00:08:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-16 00:08:06 +0200 |
commit | d2445a15a1e3bc54af3737ff85ad6c37667c538e (patch) | |
tree | e4ba908b64086a67824be6917ad6bdb2bbc4b0a7 | |
parent | 2c18e4eb25425d01d7315daf326a1bfd57577169 (diff) | |
parent | b11035693c4d10b233cac0a0afaac923592b1053 (diff) | |
download | meson-d2445a15a1e3bc54af3737ff85ad6c37667c538e.zip meson-d2445a15a1e3bc54af3737ff85ad6c37667c538e.tar.gz meson-d2445a15a1e3bc54af3737ff85ad6c37667c538e.tar.bz2 |
Merge pull request #3069 from dcbaker/pch_one_arg
Fix targets with C and C++ code that use pre compiled headers
-rw-r--r-- | mesonbuild/backend/backends.py | 14 | ||||
-rw-r--r-- | test cases/common/15 mixed pch/meson.build | 19 |
2 files changed, 20 insertions, 13 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 29c3168..62cc756 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -410,16 +410,10 @@ class Backend: args = [] pchpath = self.get_target_private_dir(target) includeargs = compiler.get_include_args(pchpath, False) - for lang in ['c', 'cpp']: - p = target.get_pch(lang) - if not p: - continue - if compiler.can_compile(p[-1]): - header = p[0] - args += compiler.get_pch_use_args(pchpath, header) - if len(args) > 0: - args = includeargs + args - return args + p = target.get_pch(compiler.get_language()) + if p: + args += compiler.get_pch_use_args(pchpath, p[0]) + return includeargs + args @staticmethod def escape_extra_args(compiler, args): diff --git a/test cases/common/15 mixed pch/meson.build b/test cases/common/15 mixed pch/meson.build index 19129d8..8e9da93 100644 --- a/test cases/common/15 mixed pch/meson.build +++ b/test cases/common/15 mixed pch/meson.build @@ -1,6 +1,19 @@ project('mixed C and C++ pch test', 'cpp', 'c') -exe = executable('prog', 'main.cc', 'func.c', -c_pch : ['pch/func.h', 'pch/func_pch.c'], -cpp_pch : ['pch/main_pch.cc', 'pch/main.h']) +exe = executable( + 'prog', + files('main.cc', 'func.c'), + c_pch : ['pch/func.h', 'pch/func_pch.c'], + cpp_pch : ['pch/main_pch.cc', 'pch/main.h'], +) + +cc = meson.get_compiler('c') +if cc.get_id() != 'msvc' + exe2 = executable( + 'prog2', + files('main.cc', 'func.c'), + c_pch : 'pch/func.h', + cpp_pch : 'pch/main.h', + ) +endif |