Qualify checks of self.version by self.id in VisualStudioC/CPPCompiler

pull/4250/head
Jon Turney 6 years ago
parent 48351e70cd
commit a025c98d30
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
  1. 10
      mesonbuild/compilers/c.py
  2. 17
      mesonbuild/compilers/cpp.py

@ -1298,7 +1298,7 @@ class VisualStudioCCompiler(CCompiler):
def get_buildtype_args(self, buildtype):
args = compilers.msvc_buildtype_args[buildtype]
if version_compare(self.version, '<18.0'):
if self.id == 'msvc' and version_compare(self.version, '<18.0'):
args = [arg for arg in args if arg != '/Gw']
return args
@ -1470,7 +1470,7 @@ class VisualStudioCCompiler(CCompiler):
# build obviously, which is why we only do this when PCH is on.
# This was added in Visual Studio 2013 (MSVC 18.0). Before that it was
# always on: https://msdn.microsoft.com/en-us/library/dn502518.aspx
if pch and version_compare(self.version, '>=18.0'):
if pch and self.id == 'msvc' and version_compare(self.version, '>=18.0'):
args = ['/FS'] + args
return args
@ -1487,7 +1487,7 @@ class VisualStudioCCompiler(CCompiler):
def get_instruction_set_args(self, instruction_set):
if self.is_64:
return vs64_instruction_set_args.get(instruction_set, None)
if self.version.split('.')[0] == '16' and instruction_set == 'avx':
if self.id == 'msvc' and self.version.split('.')[0] == '16' and instruction_set == 'avx':
# VS documentation says that this exists and should work, but
# it does not. The headers do not contain AVX intrinsics
# and the can not be called.
@ -1495,6 +1495,10 @@ class VisualStudioCCompiler(CCompiler):
return vs32_instruction_set_args.get(instruction_set, None)
def get_toolset_version(self):
if self.id == 'clang-cl':
# I have no idea
return '14.1'
# See boost/config/compiler/visualc.cpp for up to date mapping
try:
version = int(''.join(self.version.split('.')[0:2]))

@ -310,12 +310,15 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
def get_options(self):
cpp_stds = ['none', 'c++11', 'vc++11']
# Visual Studio 2015 and later
if version_compare(self.version, '>=19'):
cpp_stds.extend(['c++14', 'vc++14', 'c++latest', 'vc++latest'])
# Visual Studio 2017 and later
if version_compare(self.version, '>=19.11'):
cpp_stds.extend(['c++17', 'vc++17'])
if self.id == 'clang-cl':
cpp_stds.extend(['c++14', 'vc++14', 'c++17', 'vc++17', 'c++latest'])
else:
# Visual Studio 2015 and later
if version_compare(self.version, '>=19'):
cpp_stds.extend(['c++14', 'vc++14', 'c++latest', 'vc++latest'])
# Visual Studio 2017 and later
if version_compare(self.version, '>=19.11'):
cpp_stds.extend(['c++17', 'vc++17'])
opts = CPPCompiler.get_options(self)
opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
@ -356,7 +359,7 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
# which means setting the C++ standard version to C++14, in compilers that support it
# (i.e., after VS2015U3)
# if one is using anything before that point, one cannot set the standard.
if version_compare(self.version, '>=19.00.24210'):
if self.id == 'clang-cl' or version_compare(self.version, '>=19.00.24210'):
mlog.warning('MSVC does not support C++11; '
'attempting best effort; setting the standard to C++14')
args.append('/std:c++14')

Loading…
Cancel
Save