compilers|dependencies: Move Clang-CL specific logic out of OpenMP dep

And into the Clang-CL mixin.
pull/13356/head
Dylan Baker 7 months ago committed by Eli Schwartz
parent 3cd2cee775
commit f900b3270b
  1. 7
      mesonbuild/compilers/mixins/visualstudio.py
  2. 16
      mesonbuild/dependencies/misc.py

@ -483,3 +483,10 @@ class ClangClCompiler(VisualStudioLikeCompiler):
return converted
else:
return dep.get_compile_args()
def openmp_link_flags(self, env: Environment) -> T.List[str]:
# see https://github.com/mesonbuild/meson/issues/5298
libs = self.find_library('libomp', env, [])
if libs is None:
raise mesonlib.MesonBugException('Could not find libomp')
return super().openmp_link_flags(env) + libs

@ -105,8 +105,12 @@ class OpenMPDependency(SystemDependency):
return
# Set these now so they're available for the following compiler checks
self.compile_args.extend(self.clib_compiler.openmp_flags(environment))
self.link_args.extend(self.clib_compiler.openmp_link_flags(environment))
try:
self.compile_args.extend(self.clib_compiler.openmp_flags(environment))
self.link_args.extend(self.clib_compiler.openmp_link_flags(environment))
except mesonlib.MesonException as e:
mlog.warning('OpenMP support not available because:', str(e), fatal=False)
return
try:
openmp_date = self.clib_compiler.get_define(
@ -125,14 +129,6 @@ class OpenMPDependency(SystemDependency):
mlog.debug('This can be caused by flags such as gcc\'s `-fdirectives-only`, which affect preprocessor behavior.')
return
if self.clib_compiler.get_id() == 'clang-cl':
# this is necessary for clang-cl, see https://github.com/mesonbuild/meson/issues/5298
clangcl_openmp_link_args = self.clib_compiler.find_library("libomp", self.env, [])
if not clangcl_openmp_link_args:
mlog.log(mlog.yellow('WARNING:'), 'OpenMP found but libomp for clang-cl missing.')
return
self.link_args.extend(clangcl_openmp_link_args)
# Flang has omp_lib.h
header_names = ('omp.h', 'omp_lib.h')
for name in header_names:

Loading…
Cancel
Save