move CUDA compilation step from ocv_glob_module_sources to ocv_add_library

This commit is contained in:
Vladislav Vinogradov 2014-08-13 18:07:31 +04:00
parent 30111a786a
commit 0825120f6a
2 changed files with 26 additions and 19 deletions

View File

@ -585,25 +585,16 @@ macro(ocv_glob_module_sources)
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs}) 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}) 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 file(GLOB lib_cuda_srcs
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu" "${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu"
) )
set(cuda_objs "") file(GLOB lib_cuda_hdrs
set(lib_cuda_hdrs "") "${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp"
if(HAVE_CUDA) )
ocv_include_directories(${CUDA_INCLUDE_DIRS}) source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
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() endif()
file(GLOB cl_kernels file(GLOB cl_kernels
@ -622,7 +613,7 @@ macro(ocv_glob_module_sources)
endif() endif()
ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail} 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() endmacro()
# creates OpenCV module in current folder # creates OpenCV module in current folder

View File

@ -748,6 +748,22 @@ function(ocv_add_executable target)
endfunction() endfunction()
function(ocv_add_library target) 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}) _ocv_append_target_includes(${target})
endfunction() endfunction()