|
|
|
@ -1,60 +1,52 @@ |
|
|
|
|
|
|
|
|
|
include(FindCUDA) |
|
|
|
|
set(name "gpu") |
|
|
|
|
set(DEPS "opencv_core") |
|
|
|
|
|
|
|
|
|
if (CUDA_FOUND) |
|
|
|
|
include_directories(${CUDA_INCLUDE_DIRS}) |
|
|
|
|
link_directories(${CUDA_LIBRARIES}) |
|
|
|
|
|
|
|
|
|
#message ("CUDA_LIBRARIES = ${CUDA_LIBRARIES}") |
|
|
|
|
#message ("CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}") |
|
|
|
|
#message ("CUDA_TARGET_LINK = ${CUDA_TARGET_LINK}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) |
|
|
|
|
|
|
|
|
|
#==================================================================================== |
|
|
|
|
set(the_target "opencv_${name}") |
|
|
|
|
|
|
|
|
|
set(name "gpu") |
|
|
|
|
set(DEPS "opencv_core") |
|
|
|
|
project(${the_target}) |
|
|
|
|
|
|
|
|
|
project(opencv_${name}) |
|
|
|
|
add_definitions(-DCVAPI_EXPORTS) |
|
|
|
|
add_definitions(-DCVAPI_EXPORTS) |
|
|
|
|
|
|
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" |
|
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" |
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cuda" |
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src" |
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}") |
|
|
|
|
|
|
|
|
|
foreach(d ${DEPS}) |
|
|
|
|
foreach(d ${DEPS}) |
|
|
|
|
if(${d} MATCHES "opencv_") |
|
|
|
|
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d}) |
|
|
|
|
include_directories("${d_dir}/include") |
|
|
|
|
endif() |
|
|
|
|
endforeach() |
|
|
|
|
endforeach() |
|
|
|
|
|
|
|
|
|
file(GLOB lib_srcs "src/*.cpp") |
|
|
|
|
file(GLOB lib_int_hdrs "src/*.h*") |
|
|
|
|
file(GLOB lib_cuda "cuda/*.cu") |
|
|
|
|
file(GLOB lib_cuda_hdrs "cuda/*.h*") |
|
|
|
|
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs}) |
|
|
|
|
source_group("Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs}) |
|
|
|
|
file(GLOB lib_srcs "src/*.cpp") |
|
|
|
|
file(GLOB lib_int_hdrs "src/*.h*") |
|
|
|
|
file(GLOB lib_cuda "cuda/*.cu") |
|
|
|
|
file(GLOB lib_cuda_hdrs "cuda/*.h*") |
|
|
|
|
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs}) |
|
|
|
|
source_group("Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs}) |
|
|
|
|
|
|
|
|
|
file(GLOB lib_hdrs "include/opencv2/${name}/*.h*") |
|
|
|
|
source_group("Include" FILES ${lib_hdrs}) |
|
|
|
|
file(GLOB lib_hdrs "include/opencv2/${name}/*.h*") |
|
|
|
|
source_group("Include" FILES ${lib_hdrs}) |
|
|
|
|
|
|
|
|
|
if (HAVE_CUDA) |
|
|
|
|
include_directories(${CUDA_INCLUDE_DIRS}) |
|
|
|
|
link_directories(${CUDA_LIBRARIES}) |
|
|
|
|
|
|
|
|
|
if (UNIX OR APPLE) |
|
|
|
|
set (CUDA_NVCC_FLAGS "-Xcompiler;-fPIC") |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
CUDA_COMPILE(cuda_objs ${lib_cuda}) |
|
|
|
|
#message ("lib cuda : ${cuda_objs}") |
|
|
|
|
#CUDA_BUILD_CLEAN_TARGET() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
set(the_target "opencv_${name}") |
|
|
|
|
#message ("cuda_add_library : ${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs}") |
|
|
|
|
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${cuda_objs}) |
|
|
|
|
|
|
|
|
|
if(PCHSupport_FOUND) |
|
|
|
|
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${cuda_objs}) |
|
|
|
|
|
|
|
|
|
if(PCHSupport_FOUND) |
|
|
|
|
set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp) |
|
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*") |
|
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Visual*") |
|
|
|
@ -64,28 +56,27 @@ if (CUDA_FOUND) |
|
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles") |
|
|
|
|
add_precompiled_header(${the_target} ${pch_header}) |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
# For dynamic link numbering convenions |
|
|
|
|
set_target_properties(${the_target} PROPERTIES |
|
|
|
|
# For dynamic link numbering convenions |
|
|
|
|
set_target_properties(${the_target} PROPERTIES |
|
|
|
|
VERSION ${OPENCV_VERSION} |
|
|
|
|
SOVERSION ${OPENCV_SOVERSION} |
|
|
|
|
OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Additional target properties |
|
|
|
|
set_target_properties(${the_target} PROPERTIES |
|
|
|
|
# Additional target properties |
|
|
|
|
set_target_properties(${the_target} PROPERTIES |
|
|
|
|
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" |
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/" |
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/" |
|
|
|
|
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Add the required libraries for linking: |
|
|
|
|
#message (" ++++ target_link_libraries = ${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} ${CUDA_LIBRARIES}") |
|
|
|
|
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} ${CUDA_LIBRARIES}) |
|
|
|
|
# Add the required libraries for linking: |
|
|
|
|
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} ${CUDA_LIBRARIES}) |
|
|
|
|
|
|
|
|
|
if(MSVC) |
|
|
|
|
if(MSVC) |
|
|
|
|
if(CMAKE_CROSSCOMPILING) |
|
|
|
|
set_target_properties(${the_target} PROPERTIES |
|
|
|
|
LINK_FLAGS "/NODEFAULTLIB:secchk" |
|
|
|
@ -94,19 +85,18 @@ if (CUDA_FOUND) |
|
|
|
|
set_target_properties(${the_target} PROPERTIES |
|
|
|
|
LINK_FLAGS "/NODEFAULTLIB:libc" |
|
|
|
|
) |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
# Dependencies of this target: |
|
|
|
|
add_dependencies(${the_target} ${DEPS}) |
|
|
|
|
# Dependencies of this target: |
|
|
|
|
add_dependencies(${the_target} ${DEPS}) |
|
|
|
|
|
|
|
|
|
install(TARGETS ${the_target} |
|
|
|
|
install(TARGETS ${the_target} |
|
|
|
|
RUNTIME DESTINATION bin COMPONENT main |
|
|
|
|
LIBRARY DESTINATION lib COMPONENT main |
|
|
|
|
ARCHIVE DESTINATION lib COMPONENT main) |
|
|
|
|
|
|
|
|
|
install(FILES ${lib_hdrs} |
|
|
|
|
install(FILES ${lib_hdrs} |
|
|
|
|
DESTINATION include/opencv2/${name} |
|
|
|
|
COMPONENT main) |
|
|
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|