cuda+npp version check at configure time.
authorAnatoly Baksheev <no@email>
Thu, 25 Nov 2010 10:42:09 +0000 (10:42 +0000)
committerAnatoly Baksheev <no@email>
Thu, 25 Nov 2010 10:42:09 +0000 (10:42 +0000)
CMakeLists.txt
modules/gpu/CMakeLists.txt
modules/gpu/FindNPP.cmake
modules/gpu/src/precomp.hpp

index f0bba02..f6a29bb 100644 (file)
@@ -647,11 +647,11 @@ endif()
 ############################### CUDA ################################\r
 \r
 if (WITH_CUDA)\r
-       find_package(CUDA)\r
-       if (CUDA_FOUND)\r
-               message(STATUS "CUDA detected.")\r
+       find_package(CUDA 3.2)\r
+       if (CUDA_FOUND)         \r
                set(HAVE_CUDA 1)\r
-\r
+               message(STATUS "CUDA detected: " ${CUDA_VERSION})\r
+               \r
                set(CUDA_COMPUTE_CAPABILITIES " 1.0 1.1 1.2 1.3 2.0 " CACHE STRING "Add or remove compute capability")\r
                set(CUDA_NVCC_FLAGS_ARCH ${CUDA_COMPUTE_CAPABILITIES})\r
 \r
index 5694478..8181c3d 100644 (file)
@@ -35,7 +35,8 @@ source_group("Include" FILES ${lib_hdrs})
 if (HAVE_CUDA)         \r
        get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH)\r
        set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp}) \r
-       find_package(NPP REQUIRED)\r
+       find_package(NPP 3.2.16 REQUIRED)\r
+       message(STATUS "NPP detected: " ${NPP_VERSION})\r
 \r
        include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_NPP_INCLUDES})  \r
        \r
index 1bf0189..c3b6257 100644 (file)
@@ -95,26 +95,29 @@ if(EXISTS ${CUDA_NPP_INCLUDES}/nppversion.h)
        string( REGEX MATCH "[0-9]+" npp_major ${npp_major} ) \r
        string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} ) \r
        string( REGEX MATCH "[0-9]+" npp_build ${npp_build} )   \r
-       set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}")\r
-       MESSAGE(STATUS "Npp version: " ${NPP_VERSION})\r
+       set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}")      \r
 endif()\r
-
+\r
 if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h)\r
-       set(CUDA_NPP_FOUND FALSE)\r
-       unset(CUDA_NPP_INCLUDES CACHE)\r
-       unset(CUDA_NPP_LIBRARIES CACHE)\r
-       \r
+       set(CUDA_NPP_FOUND FALSE)       \r
        message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.")     \r
 endif()\r
-       \r
+\r
+include( FindPackageHandleStandardArgs ) \r
+find_package_handle_standard_args( NPP \r
+       REQUIRED_VARS \r
+               CUDA_NPP_INCLUDES \r
+               CUDA_NPP_LIBRARIES \r
+       VERSION_VAR \r
+               NPP_VERSION)\r
+\r
 if(APPLE)\r
-       # We need to add the path to cudart to the linker using rpath, since the\r
-       # library name for the cuda libraries is prepended with @rpath.\r
+       # 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.\r
        get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH)\r
        if(_cuda_path_to_npp)\r
                list(APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}")\r
        endif()\r
-endif()        \r
+endif()\r
 \r
 set(CUDA_NPP_FOUND TRUE)\r
 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)\r
index a0ec26a..8f1ced7 100644 (file)
     #include "opencv2/gpu/stream_accessor.hpp"\r
     #include "npp.h"    \r
 \r
+#define CUDART_MINIMUM_REQUIRED_VERSION 3020\r
 #define NPP_MINIMUM_REQUIRED_VERSION 3216\r
 \r
+#if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION)\r
+    #error "Insufficient Cuda Runtime library version, please update it."\r
+#endif\r
+\r
 #if (NPP_VERSION_MAJOR*1000+NPP_VERSION_MINOR*100+NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION)\r
     #error "Insufficient NPP version, please update it."\r
 #endif\r
 \r
+\r
 #else /* defined(HAVE_CUDA) */\r
 \r
     static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compilled without GPU support"); }\r