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:
Seungha Yang 2019-05-08 19:26:03 +09:00
parent cae6b7112d
commit 9d6e2e364c
2 changed files with 55 additions and 49 deletions

View file

@ -27,38 +27,6 @@ cudart_dep = dependency('', required : false)
cuda_libdir = '' cuda_libdir = ''
cuda_incdir = '' cuda_incdir = ''
if host_machine.system() == 'windows'
# On windows, CUDA_PATH env will be set by installer
cuda_root = run_command(python3, '-c', 'import os; print(os.environ.get("CUDA_PATH"))').stdout().strip()
if cuda_root != '' and cuda_root != 'None'
arc = ''
if build_machine.cpu_family() == 'x86_64'
arc = 'x64'
else
arc = 'Win32'
endif
cuda_libdir = join_paths (cuda_root, 'lib', arc)
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)
if cuda_header_found and cuda_lib_found
cuda_dep = declare_dependency(include_directories: include_directories(cuda_incdir),
dependencies: cuda_lib)
endif
endif
if cudart_lib.found()
cudart_header_found = cc.has_header('cuda_runtime_api.h', args: '-I' + cuda_incdir)
cudart_lib_found = cc.has_function('cudaGetErrorString', dependencies: cudart_lib)
if cudart_header_found and cudart_lib_found
cudart_dep = declare_dependency(dependencies: cudart_lib)
endif
endif
endif
else
cuda_versions = [ cuda_versions = [
'10.1', '10.1',
'10.0', '10.0',
@ -100,6 +68,44 @@ else
cudart_dep = dependency('', required : false) cudart_dep = dependency('', required : false)
endif endif
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'
else
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)
if cuda_header_found and cuda_lib_found
cuda_dep = declare_dependency(include_directories: include_directories(cuda_incdir),
dependencies: cuda_lib)
endif
endif
if cudart_lib.found()
cudart_header_found = cc.has_header('cuda_runtime_api.h', args: '-I' + cuda_incdir)
cudart_lib_found = cc.has_function('cudaGetErrorString', dependencies: cudart_lib)
if cudart_header_found and cudart_lib_found
cudart_dep = declare_dependency(dependencies: cudart_lib)
endif
endif
endif
endif endif
if cuda_dep.found() and cudart_dep.found() if cuda_dep.found() and cudart_dep.found()

View file

@ -13,7 +13,7 @@ if nvenc_option.disabled()
subdir_done() subdir_done()
endif endif
if host_machine.system() == 'windows' if cuda_dep.type_name() == 'internal'
if cc.has_header('cuda_gl_interop.h', args: '-I' + cuda_incdir) if cc.has_header('cuda_gl_interop.h', args: '-I' + cuda_incdir)
use_nvenc_gl = true use_nvenc_gl = true
endif endif