Merge pull request #3103 from vpisarev:core_imgproc_optim_rearrangements
[profile/ivi/opencv.git] / cmake / OpenCVUtils.cmake
index a7d449f..96321f9 100644 (file)
@@ -94,7 +94,7 @@ function(ocv_target_include_directories target)
       list(APPEND __params "${dir}")
     endif()
   endforeach()
-  if(CMAKE_VERSION VERSION_LESS 2.8.11)
+  if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11)
     include_directories(${__params})
   else()
     if(TARGET ${target})
@@ -748,6 +748,22 @@ function(ocv_add_executable target)
 endfunction()
 
 function(ocv_add_library target)
-  add_library(${target} ${ARGN})
+  set(cuda_objs "")
+  if(HAVE_CUDA)
+    set(cuda_srcs "")
+
+    foreach(var ${ARGN})
+      if(var MATCHES ".cu")
+        list(APPEND cuda_srcs ${var})
+      endif()
+    endforeach()
+
+    if(cuda_srcs)
+      ocv_include_directories(${CUDA_INCLUDE_DIRS})
+      ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
+    endif()
+  endif()
+
+  add_library(${target} ${ARGN} ${cuda_objs})
   _ocv_append_target_includes(${target})
-endfunction()
\ No newline at end of file
+endfunction()