msvc: Avoid spurious openmp link warnings

The linker that comes with MSVC does not understand the /openmp flag.
This results in a string of

    LINK : warning LNK4044: unrecognized option '/openmp'; ignored

warnings, one for each static_library linked with an executable.

Avoid this by only setting the linker openmp flag when the compiler is
not MSVC.
pull/7256/head
Peter Harris 5 years ago committed by Peter Harris
parent 2e30afb23b
commit 9462f0c7bc
  1. 3
      mesonbuild/compilers/compilers.py
  2. 3
      mesonbuild/compilers/mixins/visualstudio.py
  3. 3
      mesonbuild/dependencies/misc.py

@ -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