diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2023-02-07 14:10:37 -0800 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2023-02-19 02:55:58 +0530 |
commit | 320be0b6b3ba59008a5886af48c6e0da2c19050d (patch) | |
tree | f6275d9438ba0e7289f9d96da77deafb619c0ec9 | |
parent | b68102102ccbfcb69398b06c751fc2b4fa19fbc4 (diff) | |
download | meson-320be0b6b3ba59008a5886af48c6e0da2c19050d.zip meson-320be0b6b3ba59008a5886af48c6e0da2c19050d.tar.gz meson-320be0b6b3ba59008a5886af48c6e0da2c19050d.tar.bz2 |
compilers: Optimize the /Zc:__cplusplus code
This could also be handled once, in the initializer
-rw-r--r-- | mesonbuild/compilers/cpp.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index ab8b323..4466a1b 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -717,6 +717,12 @@ class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixi info, exe_wrapper, linker=linker, full_version=full_version) MSVCCompiler.__init__(self, target) + # By default, MSVC has a broken __cplusplus define that pretends to be c++98: + # https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160 + # Pass the flag to enable a truthful define, if possible. + if version_compare(self.version, '>= 19.14.26428'): + self.always_args = self.always_args + ['/Zc:__cplusplus'] + def get_options(self) -> 'MutableKeyedOptionDictType': cpp_stds = ['none', 'c++11', 'vc++11'] # Visual Studio 2015 and later @@ -746,16 +752,6 @@ class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixi del args[i] return args - def get_always_args(self) -> T.List[str]: - args = super().get_always_args() - - # By default, MSVC has a broken __cplusplus define that pretends to be c++98: - # https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160 - # Pass the flag to enable a truthful define, if possible. - if version_compare(self.version, '>= 19.14.26428') and '/Zc:__cplusplus' not in args: - return args + ['/Zc:__cplusplus'] - return args - class ClangClCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixin, ClangClCompiler, CPPCompiler): id = 'clang-cl' |