fixed build with CUDA 5.5 on arm platforms
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 18 Jun 2013 13:46:57 +0000 (17:46 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Tue, 18 Jun 2013 13:46:57 +0000 (17:46 +0400)
cmake/OpenCVDetectCUDA.cmake
modules/gpu/CMakeLists.txt

index 8db6677..3b93f29 100644 (file)
@@ -29,10 +29,42 @@ if(CUDA_FOUND)
   if(${CUDA_VERSION} VERSION_LESS "5.5")
     find_cuda_helper_libs(npp)
   else()
-    find_cuda_helper_libs(nppc)
-    find_cuda_helper_libs(nppi)
-    find_cuda_helper_libs(npps)
-    set(CUDA_npp_LIBRARY ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
+    # hack for CUDA 5.5
+    if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
+      unset(CUDA_TOOLKIT_INCLUDE CACHE)
+      unset(CUDA_CUDART_LIBRARY CACHE)
+      unset(CUDA_cublas_LIBRARY CACHE)
+      unset(CUDA_cufft_LIBRARY CACHE)
+      unset(CUDA_npp_LIBRARY CACHE)
+
+      if(SOFTFP)
+        set(cuda_arm_path "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabi")
+      else()
+        set(cuda_arm_path "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf")
+      endif()
+
+      set(CUDA_TOOLKIT_INCLUDE "${cuda_arm_path}/include" CACHE PATH "include path")
+      set(CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE})
+
+      set(cuda_arm_library_path "${cuda_arm_path}/lib")
+
+      set(CUDA_CUDART_LIBRARY "${cuda_arm_library_path}/libcudart.so" CACHE FILEPATH "cudart library")
+      set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY})
+      set(CUDA_cublas_LIBRARY "${cuda_arm_library_path}/libcublas.so" CACHE FILEPATH "cublas library")
+      set(CUDA_cufft_LIBRARY "${cuda_arm_library_path}/libcufft.so" CACHE FILEPATH "cufft library")
+      set(CUDA_nppc_LIBRARY "${cuda_arm_library_path}/libnppc.so" CACHE FILEPATH "nppc library")
+      set(CUDA_nppi_LIBRARY "${cuda_arm_library_path}/libnppi.so" CACHE FILEPATH "nppi library")
+      set(CUDA_npps_LIBRARY "${cuda_arm_library_path}/libnpps.so" CACHE FILEPATH "npps library")
+      set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}" CACHE STRING "npp library")
+    else()
+      unset(CUDA_npp_LIBRARY CACHE)
+
+      find_cuda_helper_libs(nppc)
+      find_cuda_helper_libs(nppi)
+      find_cuda_helper_libs(npps)
+
+      set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}" CACHE STRING "npp library")
+    endif()
   endif()
 
   if(WITH_NVCUVID)
index 0062944..44b5072 100644 (file)
@@ -43,6 +43,14 @@ if(HAVE_CUDA)
   ocv_cuda_compile(cuda_objs ${lib_cuda} ${ncv_cuda})
 
   set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
+  
+  if(HAVE_CUFFT)
+      set(cuda_link_libs ${cuda_link_libs} ${CUDA_cufft_LIBRARY})
+  endif()
+
+  if(HAVE_CUBLAS)
+      set(cuda_link_libs ${cuda_link_libs} ${CUDA_cublas_LIBRARY})
+  endif()
 
   if(WITH_NVCUVID)
     set(cuda_link_libs ${cuda_link_libs} ${CUDA_CUDA_LIBRARY} ${CUDA_nvcuvid_LIBRARY})
@@ -71,14 +79,6 @@ ocv_set_module_sources(
 ocv_create_module(${cuda_link_libs})
 
 if(HAVE_CUDA)
-  if(HAVE_CUFFT)
-    CUDA_ADD_CUFFT_TO_TARGET(${the_module})
-  endif()
-
-  if(HAVE_CUBLAS)
-    CUDA_ADD_CUBLAS_TO_TARGET(${the_module})
-  endif()
-
   install(FILES src/nvidia/NPP_staging/NPP_staging.hpp  src/nvidia/core/NCV.hpp
     DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2/${name}
     COMPONENT main)