mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
meson: Allow CUDA_PATH fallback on linux
That's what we've supported via autotools build Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/966
This commit is contained in:
parent
cae6b7112d
commit
9d6e2e364c
2 changed files with 55 additions and 49 deletions
|
@ -27,10 +27,52 @@ cudart_dep = dependency('', required : false)
|
|||
cuda_libdir = ''
|
||||
cuda_incdir = ''
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
# On windows, CUDA_PATH env will be set by installer
|
||||
cuda_versions = [
|
||||
'10.1',
|
||||
'10.0',
|
||||
'9.2',
|
||||
'9.1',
|
||||
'9.0',
|
||||
'8.0',
|
||||
'7.5',
|
||||
'7.0',
|
||||
'6.5',
|
||||
]
|
||||
cuda_ver = ''
|
||||
|
||||
# FIXME: use break syntax when we use meson >= '0.49'
|
||||
foreach v : cuda_versions
|
||||
if cuda_ver == ''
|
||||
cuda_dep = dependency('cuda-' + v, required: false)
|
||||
cudart_dep = dependency('cudart-' + v, required: false)
|
||||
if cuda_dep.found() and cudart_dep.found()
|
||||
cuda_ver = v
|
||||
endif
|
||||
endif
|
||||
endforeach
|
||||
|
||||
if cuda_dep.found()
|
||||
cuda_header_found = cc.has_header('cuda.h', dependencies: cuda_dep)
|
||||
cuda_lib_found = cc.has_function('cuInit', dependencies: cuda_dep)
|
||||
if not cuda_header_found or not cuda_lib_found
|
||||
message ('Missing required header and/or function in cuda dependency')
|
||||
cuda_dep = dependency('', required : false)
|
||||
endif
|
||||
endif
|
||||
|
||||
if cudart_dep.found()
|
||||
cudart_header_found = cc.has_header('cuda_runtime_api.h', dependencies: cudart_dep)
|
||||
cudart_lib_found = cc.has_function('cudaGetErrorString', dependencies: cudart_dep)
|
||||
if not cudart_header_found or not cudart_lib_found
|
||||
message ('Missing required header and/or function in cudart dependency')
|
||||
cudart_dep = dependency('', required : false)
|
||||
endif
|
||||
endif
|
||||
|
||||
if not cuda_dep.found() or not cudart_dep.found()
|
||||
cuda_root = run_command(python3, '-c', 'import os; print(os.environ.get("CUDA_PATH"))').stdout().strip()
|
||||
if cuda_root != '' and cuda_root != 'None'
|
||||
if host_machine.system() == 'windows'
|
||||
arc = ''
|
||||
if build_machine.cpu_family() == 'x86_64'
|
||||
arc = 'x64'
|
||||
|
@ -38,9 +80,14 @@ if host_machine.system() == 'windows'
|
|||
arc = 'Win32'
|
||||
endif
|
||||
cuda_libdir = join_paths (cuda_root, 'lib', arc)
|
||||
else
|
||||
cuda_libdir = [join_paths (cuda_root, 'lib'), join_paths (cuda_root, 'lib', 'stubs'),
|
||||
join_paths (cuda_root, 'lib64'), join_paths (cuda_root, 'lib64', 'stubs')]
|
||||
endif
|
||||
cuda_incdir = join_paths (cuda_root, 'include')
|
||||
cuda_lib = cc.find_library('cuda', dirs: cuda_libdir, required: false)
|
||||
cudart_lib = cc.find_library('cudart', dirs: cuda_libdir, required: false)
|
||||
|
||||
if cuda_lib.found()
|
||||
cuda_header_found = cc.has_header('cuda.h', args: '-I' + cuda_incdir)
|
||||
cuda_lib_found = cc.has_function('cuInit', dependencies: cuda_lib)
|
||||
|
@ -57,48 +104,7 @@ if host_machine.system() == 'windows'
|
|||
cudart_dep = declare_dependency(dependencies: cudart_lib)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
cuda_versions = [
|
||||
'10.1',
|
||||
'10.0',
|
||||
'9.2',
|
||||
'9.1',
|
||||
'9.0',
|
||||
'8.0',
|
||||
'7.5',
|
||||
'7.0',
|
||||
'6.5',
|
||||
]
|
||||
cuda_ver = ''
|
||||
|
||||
# FIXME: use break syntax when we use meson >= '0.49'
|
||||
foreach v : cuda_versions
|
||||
if cuda_ver == ''
|
||||
cuda_dep = dependency('cuda-' + v, required: false)
|
||||
cudart_dep = dependency('cudart-' + v, required: false)
|
||||
if cuda_dep.found() and cudart_dep.found()
|
||||
cuda_ver = v
|
||||
endif
|
||||
endif
|
||||
endforeach
|
||||
|
||||
if cuda_dep.found()
|
||||
cuda_header_found = cc.has_header('cuda.h', dependencies: cuda_dep)
|
||||
cuda_lib_found = cc.has_function('cuInit', dependencies: cuda_dep)
|
||||
if not cuda_header_found or not cuda_lib_found
|
||||
message ('Missing required header and/or function in cuda dependency')
|
||||
cuda_dep = dependency('', required : false)
|
||||
endif
|
||||
endif
|
||||
|
||||
if cudart_dep.found()
|
||||
cudart_header_found = cc.has_header('cuda_runtime_api.h', dependencies: cudart_dep)
|
||||
cudart_lib_found = cc.has_function('cudaGetErrorString', dependencies: cudart_dep)
|
||||
if not cudart_header_found or not cudart_lib_found
|
||||
message ('Missing required header and/or function in cudart dependency')
|
||||
cudart_dep = dependency('', required : false)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ if nvenc_option.disabled()
|
|||
subdir_done()
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
if cuda_dep.type_name() == 'internal'
|
||||
if cc.has_header('cuda_gl_interop.h', args: '-I' + cuda_incdir)
|
||||
use_nvenc_gl = true
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue