move CUDA compilation step from ocv_glob_module_sources to ocv_add_library

pull/3098/head
Vladislav Vinogradov 10 years ago
parent 30111a786a
commit 0825120f6a
  1. 17
      cmake/OpenCVModule.cmake
  2. 18
      cmake/OpenCVUtils.cmake

@ -585,26 +585,17 @@ macro(ocv_glob_module_sources)
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
if (exclude_cuda EQUAL -1)
set(lib_cuda_srcs "")
set(lib_cuda_hdrs "")
if(HAVE_CUDA AND exclude_cuda EQUAL -1)
file(GLOB lib_cuda_srcs
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu"
)
set(cuda_objs "")
set(lib_cuda_hdrs "")
if(HAVE_CUDA)
ocv_include_directories(${CUDA_INCLUDE_DIRS})
file(GLOB lib_cuda_hdrs
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp"
)
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
endif()
else()
set(cuda_objs "")
set(lib_cuda_srcs "")
set(lib_cuda_hdrs "")
endif()
file(GLOB cl_kernels
"${CMAKE_CURRENT_LIST_DIR}/src/opencl/*.cl"
@ -622,7 +613,7 @@ macro(ocv_glob_module_sources)
endif()
ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
SOURCES ${lib_srcs} ${lib_int_hdrs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
endmacro()
# creates OpenCV module in current folder

@ -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()
Loading…
Cancel
Save