fix corner case of libnvcuvid

* detect header automatically and not based on version number
This commit is contained in:
Tomoaki Teshima 2020-06-11 23:06:18 +09:00
parent 476aa443c6
commit d4af89781b
7 changed files with 32 additions and 11 deletions

View File

@ -38,11 +38,30 @@ if(CUDA_FOUND)
endif()
if(WITH_NVCUVID)
macro(SEARCH_NVCUVID_HEADER _filename _result)
# place header file under CUDA_TOOLKIT_TARGET_DIR or CUDA_TOOLKIT_ROOT_DIR
find_path(_header_result
${_filename}
PATHS "${CUDA_TOOLKIT_TARGET_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}"
ENV CUDA_PATH
ENV CUDA_INC_PATH
PATH_SUFFIXES include
NO_DEFAULT_PATH
)
if("x${_header_result}" STREQUAL "x_header_result-NOTFOUND")
set(${_result} 0)
else()
set(${_result} 1)
endif()
endmacro()
SEARCH_NVCUVID_HEADER("nvcuvid.h" HAVE_NVCUVID_HEADER)
SEARCH_NVCUVID_HEADER("dynlink_nvcuvid.h" HAVE_DYNLINK_NVCUVID_HEADER)
find_cuda_helper_libs(nvcuvid)
if(WIN32)
find_cuda_helper_libs(nvcuvenc)
endif()
if(CUDA_nvcuvid_LIBRARY)
if(CUDA_nvcuvid_LIBRARY AND (${HAVE_NVCUVID_HEADER} OR ${HAVE_DYNLINK_NVCUVID_HEADER}))
# make sure to have both header and library before enabling
set(HAVE_NVCUVID 1)
endif()
if(CUDA_nvcuvenc_LIBRARY)

View File

@ -127,6 +127,8 @@
/* NVIDIA Video Decoding API*/
#cmakedefine HAVE_NVCUVID
#cmakedefine HAVE_NVCUVID_HEADER
#cmakedefine HAVE_DYNLINK_NVCUVID_HEADER
/* NVIDIA Video Encoding API*/
#cmakedefine HAVE_NVCUVENC

View File

@ -44,9 +44,9 @@
#ifndef __CUVID_VIDEO_SOURCE_HPP__
#define __CUVID_VIDEO_SOURCE_HPP__
#if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
#if defined(HAVE_DYNLINK_NVCUVID_HEADER)
#include <dynlink_nvcuvid.h>
#else
#elif defined(HAVE_NVCUVID_HEADER)
#include <nvcuvid.h>
#endif
#include "opencv2/core/private.cuda.hpp"

View File

@ -47,9 +47,9 @@
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.cuda.hpp"
#if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
#if defined(HAVE_DYNLINK_NVCUVID_HEADER)
#include <dynlink_nvcuvid.h>
#else
#elif defined(HAVE_NVCUVID_HEADER)
#include <nvcuvid.h>
#endif

View File

@ -56,9 +56,9 @@
#include "opencv2/core/private.cuda.hpp"
#ifdef HAVE_NVCUVID
#if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
#if defined(HAVE_DYNLINK_NVCUVID_HEADER)
#include <dynlink_nvcuvid.h>
#else
#elif defined(HAVE_NVCUVID_HEADER)
#include <nvcuvid.h>
#endif

View File

@ -44,9 +44,9 @@
#ifndef __VIDEO_DECODER_HPP__
#define __VIDEO_DECODER_HPP__
#if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
#if defined(HAVE_DYNLINK_NVCUVID_HEADER)
#include <dynlink_nvcuvid.h>
#else
#elif defined(HAVE_NVCUVID_HEADER)
#include <nvcuvid.h>
#endif

View File

@ -44,9 +44,9 @@
#ifndef __VIDEO_PARSER_HPP__
#define __VIDEO_PARSER_HPP__
#if CUDA_VERSION >= 9000 && CUDA_VERSION < 10000
#if defined(HAVE_DYNLINK_NVCUVID_HEADER)
#include <dynlink_nvcuvid.h>
#else
#elif defined(HAVE_NVCUVID_HEADER)
#include <nvcuvid.h>
#endif