|
|
|
@ -479,39 +479,49 @@ endmacro() |
|
|
|
|
# finds and sets headers and sources for the standard OpenCV module |
|
|
|
|
# Usage: |
|
|
|
|
# ocv_glob_module_sources(<extra sources&headers in the same format as used in ocv_set_module_sources>) |
|
|
|
|
macro(ocv_glob_module_sources) |
|
|
|
|
macro(ocv_glob_module_sources EXCLUDE_CUDA EXCLUDE_OPENCL) |
|
|
|
|
file(GLOB_RECURSE lib_srcs "src/*.cpp") |
|
|
|
|
file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h") |
|
|
|
|
file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") |
|
|
|
|
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h") |
|
|
|
|
|
|
|
|
|
file(GLOB lib_cuda_srcs "src/cuda/*.cu") |
|
|
|
|
set(cuda_objs "") |
|
|
|
|
set(lib_cuda_hdrs "") |
|
|
|
|
if(HAVE_CUDA) |
|
|
|
|
ocv_include_directories(${CUDA_INCLUDE_DIRS}) |
|
|
|
|
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp") |
|
|
|
|
if (NOT ${EXCLUDE_CUDA}) |
|
|
|
|
file(GLOB lib_cuda_srcs "src/cuda/*.cu") |
|
|
|
|
set(cuda_objs "") |
|
|
|
|
set(lib_cuda_hdrs "") |
|
|
|
|
if(HAVE_CUDA) |
|
|
|
|
ocv_include_directories(${CUDA_INCLUDE_DIRS}) |
|
|
|
|
file(GLOB lib_cuda_hdrs "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}) |
|
|
|
|
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() |
|
|
|
|
|
|
|
|
|
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs}) |
|
|
|
|
|
|
|
|
|
file(GLOB cl_kernels "src/opencl/*.cl") |
|
|
|
|
if(HAVE_opencv_ocl AND cl_kernels) |
|
|
|
|
ocv_include_directories(${OPENCL_INCLUDE_DIRS}) |
|
|
|
|
add_custom_command( |
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp" |
|
|
|
|
COMMAND ${CMAKE_COMMAND} -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake" |
|
|
|
|
DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake") |
|
|
|
|
source_group("OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp") |
|
|
|
|
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp") |
|
|
|
|
if (NOT ${EXCLUDE_OPENCL}) |
|
|
|
|
file(GLOB cl_kernels "src/opencl/*.cl") |
|
|
|
|
if(HAVE_opencv_ocl AND cl_kernels) |
|
|
|
|
ocv_include_directories(${OPENCL_INCLUDE_DIRS}) |
|
|
|
|
add_custom_command( |
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp" |
|
|
|
|
COMMAND ${CMAKE_COMMAND} -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake" |
|
|
|
|
DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake") |
|
|
|
|
source_group("OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp") |
|
|
|
|
list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp") |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
source_group("Include" FILES ${lib_hdrs}) |
|
|
|
|
source_group("Include\\detail" FILES ${lib_hdrs_detail}) |
|
|
|
|
|
|
|
|
|
message(":${EXCLUDE_CUDA}: ${lib_cuda_srcs}") |
|
|
|
|
|
|
|
|
|
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}) |
|
|
|
|
endmacro() |
|
|
|
@ -614,9 +624,25 @@ endmacro() |
|
|
|
|
# Usage: |
|
|
|
|
# ocv_define_module(module_name [INTERNAL] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>]) |
|
|
|
|
macro(ocv_define_module module_name) |
|
|
|
|
ocv_add_module(${module_name} ${ARGN}) |
|
|
|
|
set(_tmp_argn ${ARGN}) |
|
|
|
|
set(exclude_cuda 0) |
|
|
|
|
set(exclude_opencl 0) |
|
|
|
|
set(argv0 ${ARGV1}) |
|
|
|
|
set(argv1 ${ARGV2}) |
|
|
|
|
set(argv2 ${ARGV3}) |
|
|
|
|
foreach(i RANGE 0 2) |
|
|
|
|
if("${argv${i}}" STREQUAL "EXCLUDE_CUDA") |
|
|
|
|
set(exclude_cuda 1) |
|
|
|
|
list(REMOVE_AT _tmp_argn ${i}) |
|
|
|
|
elseif ("${argv${i}}" STREQUAL "EXCLUDE_OPENCL") |
|
|
|
|
set(exclude_opencl 1) |
|
|
|
|
list(REMOVE_AT _tmp_argn ${i}) |
|
|
|
|
endif() |
|
|
|
|
endforeach() |
|
|
|
|
|
|
|
|
|
ocv_add_module(${module_name} ${_tmp_argn}) |
|
|
|
|
ocv_module_include_directories() |
|
|
|
|
ocv_glob_module_sources() |
|
|
|
|
ocv_glob_module_sources(${exclude_cuda} ${exclude_opencl}) |
|
|
|
|
ocv_create_module() |
|
|
|
|
ocv_add_precompiled_headers(${the_module}) |
|
|
|
|
|
|
|
|
|