From 36ebf4ef0dce1bb9027291c768a016291c4a28f7 Mon Sep 17 00:00:00 2001 From: Anatoly Baksheev Date: Thu, 25 Nov 2010 10:42:09 +0000 Subject: [PATCH] cuda+npp version check at configure time. --- CMakeLists.txt | 8 ++++---- modules/gpu/CMakeLists.txt | 3 ++- modules/gpu/FindNPP.cmake | 25 ++++++++++++++----------- modules/gpu/src/precomp.hpp | 6 ++++++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0bba02..f6a29bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -647,11 +647,11 @@ endif() ############################### CUDA ################################ if (WITH_CUDA) - find_package(CUDA) - if (CUDA_FOUND) - message(STATUS "CUDA detected.") + find_package(CUDA 3.2) + if (CUDA_FOUND) set(HAVE_CUDA 1) - + message(STATUS "CUDA detected: " ${CUDA_VERSION}) + set(CUDA_COMPUTE_CAPABILITIES " 1.0 1.1 1.2 1.3 2.0 " CACHE STRING "Add or remove compute capability") set(CUDA_NVCC_FLAGS_ARCH ${CUDA_COMPUTE_CAPABILITIES}) diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index 5694478..8181c3d 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -35,7 +35,8 @@ source_group("Include" FILES ${lib_hdrs}) if (HAVE_CUDA) get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp}) - find_package(NPP REQUIRED) + find_package(NPP 3.2.16 REQUIRED) + message(STATUS "NPP detected: " ${NPP_VERSION}) include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_NPP_INCLUDES}) diff --git a/modules/gpu/FindNPP.cmake b/modules/gpu/FindNPP.cmake index 1bf0189..c3b6257 100644 --- a/modules/gpu/FindNPP.cmake +++ b/modules/gpu/FindNPP.cmake @@ -95,26 +95,29 @@ if(EXISTS ${CUDA_NPP_INCLUDES}/nppversion.h) string( REGEX MATCH "[0-9]+" npp_major ${npp_major} ) string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} ) string( REGEX MATCH "[0-9]+" npp_build ${npp_build} ) - set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") - MESSAGE(STATUS "Npp version: " ${NPP_VERSION}) + set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") endif() - + if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h) - set(CUDA_NPP_FOUND FALSE) - unset(CUDA_NPP_INCLUDES CACHE) - unset(CUDA_NPP_LIBRARIES CACHE) - + set(CUDA_NPP_FOUND FALSE) message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.") endif() - + +include( FindPackageHandleStandardArgs ) +find_package_handle_standard_args( NPP + REQUIRED_VARS + CUDA_NPP_INCLUDES + CUDA_NPP_LIBRARIES + VERSION_VAR + NPP_VERSION) + if(APPLE) - # We need to add the path to cudart to the linker using rpath, since the - # library name for the cuda libraries is prepended with @rpath. + # We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath. get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH) if(_cuda_path_to_npp) list(APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}") endif() -endif() +endif() set(CUDA_NPP_FOUND TRUE) set(CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL "${CUDA_NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_NPP_LIBRARY_ROOT_DIR was set successfully." FORCE) diff --git a/modules/gpu/src/precomp.hpp b/modules/gpu/src/precomp.hpp index a0ec26a..8f1ced7 100644 --- a/modules/gpu/src/precomp.hpp +++ b/modules/gpu/src/precomp.hpp @@ -67,12 +67,18 @@ #include "opencv2/gpu/stream_accessor.hpp" #include "npp.h" +#define CUDART_MINIMUM_REQUIRED_VERSION 3020 #define NPP_MINIMUM_REQUIRED_VERSION 3216 +#if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION) + #error "Insufficient Cuda Runtime library version, please update it." +#endif + #if (NPP_VERSION_MAJOR*1000+NPP_VERSION_MINOR*100+NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION) #error "Insufficient NPP version, please update it." #endif + #else /* defined(HAVE_CUDA) */ static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compilled without GPU support"); } -- 2.7.4