# Version Compute Capability from which OpenCV has been compiled is remembered set(OpenCV_COMPUTE_CAPABILITIES "@OpenCV_CUDA_CC@") set(OpenCV_CUDA_VERSION "@CUDA_VERSION_STRING@") set(OpenCV_USE_CUBLAS "@HAVE_CUBLAS@") set(OpenCV_USE_CUFFT "@HAVE_CUFFT@") set(OpenCV_USE_NVCUVID "@HAVE_NVCUVID@") set(OpenCV_USE_NVCUVENC "@HAVE_NVCUVENC@") set(OpenCV_CUDNN_VERSION "@CUDNN_VERSION@") set(OpenCV_USE_CUDNN "@HAVE_CUDNN@") set(ENABLE_CUDA_FIRST_CLASS_LANGUAGE ON) # By default OpenCV only requires the consumer's CUDA Toolkit to match the # major.minor version it was built with. The CUDA runtime API is stable within # a minor release and patch versions change frequently, so pinning the patch # component forces needless rebuilds (issue #26965). Set # OPENCV_STRONG_CUDA_VERSION_CHECK before find_package(OpenCV) to require an # exact match including the patch component. string(REGEX MATCH "^[0-9]+\\.[0-9]+" OpenCV_CUDA_VERSION_MAJOR_MINOR "${OpenCV_CUDA_VERSION}") if(NOT CUDAToolkit_FOUND) if(NOT CMAKE_VERSION VERSION_LESS 3.18) if(UNIX AND NOT CMAKE_CUDA_COMPILER AND NOT CUDAToolkit_ROOT) message(STATUS "Checking for CUDAToolkit in default location (/usr/local/cuda)") set(CUDA_PATH "/usr/local/cuda" CACHE INTERNAL "") set(ENV{CUDA_PATH} ${CUDA_PATH}) endif() if(OPENCV_STRONG_CUDA_VERSION_CHECK) find_package(CUDAToolkit ${OpenCV_CUDA_VERSION} EXACT REQUIRED) else() find_package(CUDAToolkit ${OpenCV_CUDA_VERSION_MAJOR_MINOR} REQUIRED) endif() else() message(FATAL_ERROR "Using OpenCV compiled with CUDA as first class language requires CMake \>= 3.18.") endif() endif() if(CUDAToolkit_FOUND) set(CUDA_VERSION_STRING ${CUDAToolkit_VERSION}) endif() string(REGEX MATCH "^[0-9]+\\.[0-9]+" CUDA_VERSION_STRING_MAJOR_MINOR "${CUDA_VERSION_STRING}") if(OPENCV_STRONG_CUDA_VERSION_CHECK) set(__ocv_cuda_found "${CUDA_VERSION_STRING}") set(__ocv_cuda_built "${OpenCV_CUDA_VERSION}") else() set(__ocv_cuda_found "${CUDA_VERSION_STRING_MAJOR_MINOR}") set(__ocv_cuda_built "${OpenCV_CUDA_VERSION_MAJOR_MINOR}") endif() if(NOT __ocv_cuda_found VERSION_EQUAL __ocv_cuda_built) message(FATAL_ERROR "OpenCV library was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}") endif()