summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-02-07 14:10:37 -0800
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2023-02-08 15:31:58 +0530
commitf06c0e940945785583ff209ae2619fc814bc8b36 (patch)
tree13f8fcea5e6e262168ddd1d92b23c697466b7ac4 /mesonbuild/compilers
parentd0f81fd024b8b5b0e862deb6689d7abe11427885 (diff)
downloadmeson-f06c0e940945785583ff209ae2619fc814bc8b36.tar.gz
compilers: Optimize the /Zc:__cplusplus code
This could also be handled once, in the initializer
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/cpp.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 656658729..b37f8cdc3 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -718,6 +718,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
@@ -747,16 +753,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'