aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/misc.py
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-11-27 01:35:15 -0500
committerMichael Hirsch, Ph.D <10931741+scivision@users.noreply.github.com>2019-12-09 11:15:58 -0500
commit98fd4e5557cb21affd2e2c124a132953b471a748 (patch)
treeb350f0499b18795c89378790074a790488a3c351 /mesonbuild/dependencies/misc.py
parent419a7a8f51fb68cdd40f7005394590a0963d3f32 (diff)
downloadmeson-98fd4e5557cb21affd2e2c124a132953b471a748.zip
meson-98fd4e5557cb21affd2e2c124a132953b471a748.tar.gz
meson-98fd4e5557cb21affd2e2c124a132953b471a748.tar.bz2
cmake: add project language to cmakelists.txt
cmake: get language from Meson project if not specified as depedency(..., langugage: ...) deps: add threads method:cmake dependency('threads', method: 'cmake') is useful for cmake unit tests or those who just want to find threads using cmake. cmake: project(... Fortran) generally also requires C language
Diffstat (limited to 'mesonbuild/dependencies/misc.py')
-rw-r--r--mesonbuild/dependencies/misc.py38
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):