Merge pull request #7256 from peterh/openmp

Fix OpenMP on Visual Studio
pull/3865/merge
Jussi Pakkanen 5 years ago committed by GitHub
commit 508a0d6073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mesonbuild/backend/vs2010backend.py
  2. 3
      mesonbuild/compilers/compilers.py
  3. 3
      mesonbuild/compilers/mixins/visualstudio.py
  4. 3
      mesonbuild/dependencies/misc.py

@ -992,7 +992,7 @@ class Vs2010Backend(backends.Backend):
# Cflags required by external deps might have UNIX-specific flags,
# so filter them out if needed
if isinstance(d, dependencies.OpenMPDependency):
d_compile_args = compiler.openmp_flags()
ET.SubElement(clconf, 'OpenMPSupport').text = 'true'
else:
d_compile_args = compiler.unix_args_to_native(d.get_compile_args())
for arg in d_compile_args:
@ -1100,14 +1100,14 @@ class Vs2010Backend(backends.Backend):
# Extend without reordering or de-dup to preserve `-L -l` sets
# https://github.com/mesonbuild/meson/issues/1718
if isinstance(dep, dependencies.OpenMPDependency):
extra_link_args.extend_direct(compiler.openmp_flags())
ET.SubElement(clconf, 'OpenMPSuppport').text = 'true'
else:
extra_link_args.extend_direct(dep.get_link_args())
for d in target.get_dependencies():
if isinstance(d, build.StaticLibrary):
for dep in d.get_external_deps():
if isinstance(dep, dependencies.OpenMPDependency):
extra_link_args.extend_direct(compiler.openmp_flags())
ET.SubElement(clconf, 'OpenMPSuppport').text = 'true'
else:
extra_link_args.extend_direct(dep.get_link_args())
# Add link args for c_* or cpp_* build options. Currently this only

@ -1087,6 +1087,9 @@ class Compiler:
def openmp_flags(self):
raise EnvironmentException('Language %s does not support OpenMP flags.' % self.get_display_language())
def openmp_link_flags(self):
return self.openmp_flags()
def language_stdlib_only_link_flags(self):
return []

@ -208,6 +208,9 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
def openmp_flags(self) -> T.List[str]:
return ['/openmp']
def openmp_link_flags(self) -> T.List[str]:
return []
# FIXME, no idea what these should be.
def thread_flags(self, env: 'Environment') -> T.List[str]:
return []

@ -97,7 +97,8 @@ class OpenMPDependency(ExternalDependency):
for name in header_names:
if self.clib_compiler.has_header(name, '', self.env, dependencies=[self], disable_cache=True)[0]:
self.is_found = True
self.compile_args = self.link_args = self.clib_compiler.openmp_flags()
self.compile_args = self.clib_compiler.openmp_flags()
self.link_args = self.clib_compiler.openmp_link_flags()
break
if not self.is_found:
mlog.log(mlog.yellow('WARNING:'), 'OpenMP found but omp.h missing.')

Loading…
Cancel
Save