aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py7
-rw-r--r--mesonbuild/dependencies/misc.py16
2 files changed, 13 insertions, 10 deletions
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index abcedc7..907ea07 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.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
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index f9a2e04..ffccd70 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -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: