meson: Fix building of the nvdec plugin on Windows
authorNirbheek Chauhan <nirbheek@centricular.com>
Sat, 19 Jan 2019 19:53:39 +0000 (01:23 +0530)
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>
Mon, 28 Jan 2019 13:28:01 +0000 (13:28 +0000)
Have to use the Nvidia Video Codec SDK when building with a newer CUDA
toolkit.

sys/nvdec/meson.build

index 6029147..09c60ec 100644 (file)
@@ -9,14 +9,25 @@ if nvdec_option.disabled()
 endif
 
 nvcuvid_dep_found = false
+nvcuvid_incdirs = []
 if host_machine.system() == 'windows'
-  nvcuvid_lib = cc.find_library('nvcuvid', dirs: cuda_libdir, required: nvdec_option)
+  cuda_libdirs = [cuda_libdir]
+  # NOTE: Newer CUDA toolkit versions do not ship with the nvcuvid library, and
+  # you must get it from the Nvidia Video Codec SDK. The SDK ships as a zip
+  # file, so there's no installer and you have to set this env var yourself.
+  video_sdk_root = run_command(python3, '-c', 'import os; print(os.environ.get("NVIDIA_VIDEO_CODEC_SDK_PATH"))').stdout().strip()
+  if video_sdk_root != '' and video_sdk_root != 'None'
+    cuda_libdirs += [join_paths(video_sdk_root, 'Samples', 'NvCodec', 'Lib', arc)]
+    nvcuvid_incdirs = include_directories(join_paths(video_sdk_root, 'Samples', 'NvCodec', 'NvDecoder'))
+  endif
+  nvcuvid_lib = cc.find_library('nvcuvid', dirs: cuda_libdirs, required: nvdec_option)
 else
   nvcuvid_lib = cc.find_library('nvcuvid', required: nvdec_option)
 endif
 
 if nvcuvid_lib.found() and cc.has_function('cuvidCtxLock', dependencies: nvcuvid_lib)
-  nvcuvid_dep = declare_dependency(dependencies: nvcuvid_lib)
+  nvcuvid_dep = declare_dependency(dependencies: nvcuvid_lib,
+                                   include_directories: nvcuvid_incdirs)
   nvcuvid_dep_found = true
 endif