diff options
Diffstat (limited to 'mesonbuild/dependencies/misc.py')
-rw-r--r-- | mesonbuild/dependencies/misc.py | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index bfd450c..d773eb7 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -22,6 +22,7 @@ import sysconfig from .. import mlog from .. import mesonlib from ..environment import detect_cpu_family +from ..mesonlib import listify from .base import ( DependencyException, DependencyMethods, ExternalDependency, @@ -109,15 +110,34 @@ class ThreadDependency(ExternalDependency): def __init__(self, environment, kwargs): super().__init__('threads', environment, None, kwargs) self.name = 'threads' - self.is_found = True - # Happens if you are using a language with threads - # concept without C, such as plain Cuda. - if self.clib_compiler is None: - self.compile_args = [] - self.link_args = [] - else: - self.compile_args = self.clib_compiler.thread_flags(environment) - self.link_args = self.clib_compiler.thread_link_flags(environment) + self.is_found = False + methods = listify(self.methods) + if DependencyMethods.AUTO in methods: + self.is_found = True + # Happens if you are using a language with threads + # concept without C, such as plain Cuda. + if self.clib_compiler is None: + self.compile_args = [] + self.link_args = [] + else: + self.compile_args = self.clib_compiler.thread_flags(environment) + self.link_args = self.clib_compiler.thread_link_flags(environment) + return + + if DependencyMethods.CMAKE in methods: + # for unit tests and for those who simply want + # dependency('threads', method: 'cmake') + cmakedep = CMakeDependency('Threads', environment, kwargs) + if cmakedep.found(): + self.compile_args = cmakedep.get_compile_args() + self.link_args = cmakedep.get_link_args() + self.version = cmakedep.get_version() + self.is_found = True + return + + @staticmethod + def get_methods(): + return [DependencyMethods.AUTO, DependencyMethods.CMAKE] class BlocksDependency(ExternalDependency): |