2010-12-07 00:37:32 +08:00
|
|
|
set(name "gpu")
|
|
|
|
|
|
|
|
set(the_target "opencv_${name}")
|
|
|
|
project(${the_target})
|
|
|
|
|
2011-11-09 21:13:52 +08:00
|
|
|
set(DEPS "opencv_core" "opencv_imgproc" "opencv_calib3d" "opencv_objdetect")
|
|
|
|
set(DEPS_HEADER ${DEPS} "opencv_features2d" "opencv_flann")
|
2010-12-17 23:41:26 +08:00
|
|
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} opencv_gpu)
|
|
|
|
|
2011-07-25 03:22:58 +08:00
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/cuda"
|
2010-12-07 00:37:32 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
|
|
|
|
file(GLOB lib_srcs "src/*.cpp")
|
|
|
|
file(GLOB lib_int_hdrs "src/*.h*")
|
|
|
|
file(GLOB lib_cuda "src/cuda/*.cu*")
|
|
|
|
file(GLOB lib_cuda_hdrs "src/cuda/*.h*")
|
|
|
|
source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs})
|
|
|
|
source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
|
|
|
|
|
|
|
|
file(GLOB lib_hdrs "include/opencv2/${name}/*.h*")
|
|
|
|
source_group("Include" FILES ${lib_hdrs})
|
|
|
|
|
|
|
|
#file(GLOB lib_device_hdrs "include/opencv2/${name}/device/*.h*")
|
|
|
|
file(GLOB lib_device_hdrs "src/opencv2/gpu/device/*.h*")
|
2011-08-03 20:10:36 +08:00
|
|
|
file(GLOB lib_device_hdrs_detail "src/opencv2/gpu/device/detail/*.h*")
|
2010-12-07 00:37:32 +08:00
|
|
|
source_group("Device" FILES ${lib_device_hdrs})
|
2011-08-03 20:10:36 +08:00
|
|
|
source_group("Device\\Detail" FILES ${lib_device_hdrs_detail})
|
2010-12-07 00:37:32 +08:00
|
|
|
|
2011-11-09 21:13:52 +08:00
|
|
|
foreach(d ${DEPS_HEADER})
|
|
|
|
if(${d} MATCHES "opencv_")
|
|
|
|
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d})
|
|
|
|
include_directories("${d_dir}/include")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2011-02-05 02:29:05 +08:00
|
|
|
if (HAVE_CUDA)
|
2011-02-04 23:15:25 +08:00
|
|
|
file(GLOB_RECURSE ncv_srcs "src/nvidia/*.cpp")
|
2011-02-05 02:29:05 +08:00
|
|
|
file(GLOB_RECURSE ncv_cuda "src/nvidia/*.cu")
|
2011-02-18 20:23:18 +08:00
|
|
|
file(GLOB_RECURSE ncv_hdrs "src/nvidia/*.hpp" "src/nvidia/*.h")
|
|
|
|
|
|
|
|
source_group("Src\\NVidia" FILES ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda})
|
2011-02-05 02:29:05 +08:00
|
|
|
include_directories("src/nvidia/core" "src/nvidia/NPP_staging")
|
2011-01-13 21:04:00 +08:00
|
|
|
endif()
|
|
|
|
|
2011-06-01 16:01:04 +08:00
|
|
|
if (HAVE_CUDA)
|
2011-05-18 21:02:27 +08:00
|
|
|
include_directories(${CUDA_INCLUDE_DIRS})
|
2011-02-05 02:29:05 +08:00
|
|
|
|
|
|
|
if (UNIX OR APPLE)
|
|
|
|
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-fPIC;")
|
|
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" "-fPIC")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-keep")
|
|
|
|
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
|
2011-06-01 21:57:14 +08:00
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-fno-finite-math-only;")
|
|
|
|
endif()
|
2011-02-05 02:29:05 +08:00
|
|
|
|
|
|
|
string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
|
|
string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
#string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
#string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
|
|
#string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
2011-11-09 21:13:52 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408 /wd4251")
|
2011-02-05 02:29:05 +08:00
|
|
|
|
|
|
|
string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
|
|
|
string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
|
|
|
string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
|
|
string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
|
|
|
endif()
|
2011-11-09 21:13:52 +08:00
|
|
|
|
2011-05-31 21:17:59 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2011-11-09 21:13:52 +08:00
|
|
|
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-DCVAPI_EXPORTS")
|
|
|
|
endif()
|
2011-01-13 21:04:00 +08:00
|
|
|
|
2011-11-09 21:13:52 +08:00
|
|
|
if(MSVC)
|
|
|
|
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/wd4251")
|
|
|
|
endif()
|
|
|
|
|
2011-02-05 02:29:05 +08:00
|
|
|
CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda})
|
|
|
|
#CUDA_BUILD_CLEAN_TARGET()
|
2010-12-07 00:37:32 +08:00
|
|
|
endif()
|
|
|
|
|
2011-08-03 20:10:36 +08:00
|
|
|
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${lib_device_hdrs} ${lib_device_hdrs_detail} ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda} ${cuda_objs})
|
2010-12-07 00:37:32 +08:00
|
|
|
|
|
|
|
# For dynamic link numbering convenions
|
|
|
|
set_target_properties(${the_target} PROPERTIES
|
|
|
|
VERSION ${OPENCV_VERSION}
|
|
|
|
SOVERSION ${OPENCV_SOVERSION}
|
|
|
|
OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}"
|
|
|
|
)
|
2011-05-11 21:37:20 +08:00
|
|
|
|
2011-05-17 17:40:06 +08:00
|
|
|
if(ENABLE_SOLUTION_FOLDERS)
|
2011-05-11 21:37:20 +08:00
|
|
|
set_target_properties(${the_target} PROPERTIES FOLDER "modules")
|
|
|
|
endif()
|
2011-05-07 05:45:48 +08:00
|
|
|
|
2011-05-31 22:22:25 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2011-05-11 21:50:17 +08:00
|
|
|
if (MSVC)
|
|
|
|
set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
|
|
|
|
else()
|
2011-07-25 03:22:58 +08:00
|
|
|
add_definitions(-DCVAPI_EXPORTS)
|
|
|
|
endif()
|
2011-05-07 05:45:48 +08:00
|
|
|
endif()
|
2010-12-07 00:37:32 +08:00
|
|
|
|
2011-07-25 03:22:58 +08:00
|
|
|
add_opencv_precompiled_headers(${the_target})
|
|
|
|
|
2010-12-07 00:37:32 +08:00
|
|
|
# Additional target properties
|
|
|
|
set_target_properties(${the_target} PROPERTIES
|
2011-07-25 03:22:58 +08:00
|
|
|
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
2011-05-31 06:13:32 +08:00
|
|
|
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
|
|
|
INSTALL_NAME_DIR lib
|
2011-07-25 03:22:58 +08:00
|
|
|
)
|
2010-12-07 00:37:32 +08:00
|
|
|
|
|
|
|
# Add the required libraries for linking:
|
2010-12-17 23:41:26 +08:00
|
|
|
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} )
|
2010-12-07 00:37:32 +08:00
|
|
|
|
|
|
|
if (HAVE_CUDA)
|
2011-10-19 17:53:22 +08:00
|
|
|
target_link_libraries(${the_target} ${CUDA_LIBRARIES})
|
2011-07-25 03:22:58 +08:00
|
|
|
|
|
|
|
unset(CUDA_npp_LIBRARY CACHE)
|
|
|
|
find_cuda_helper_libs(npp)
|
|
|
|
target_link_libraries(${the_target} ${CUDA_npp_LIBRARY})
|
2011-10-19 17:53:22 +08:00
|
|
|
|
|
|
|
if(HAVE_CUFFT)
|
|
|
|
CUDA_ADD_CUFFT_TO_TARGET(${the_target})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_CUBLAS)
|
|
|
|
CUDA_ADD_CUBLAS_TO_TARGET(${the_target})
|
|
|
|
endif()
|
2010-12-07 00:37:32 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC)
|
2011-07-25 03:22:58 +08:00
|
|
|
if(CMAKE_CROSSCOMPILING)
|
|
|
|
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc")
|
2010-12-07 00:37:32 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Dependencies of this target:
|
|
|
|
add_dependencies(${the_target} ${DEPS})
|
|
|
|
|
|
|
|
install(TARGETS ${the_target}
|
|
|
|
RUNTIME DESTINATION bin COMPONENT main
|
2011-08-10 20:49:52 +08:00
|
|
|
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
|
|
|
|
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
|
2010-12-07 00:37:32 +08:00
|
|
|
|
|
|
|
install(FILES ${lib_hdrs}
|
2011-06-29 00:02:09 +08:00
|
|
|
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
|
2010-12-07 00:37:32 +08:00
|
|
|
COMPONENT main)
|
|
|
|
|
2011-04-26 00:07:48 +08:00
|
|
|
install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp
|
2011-06-29 00:02:09 +08:00
|
|
|
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
|
2011-04-26 00:07:48 +08:00
|
|
|
COMPONENT main)
|
|
|
|
|
2010-12-07 00:37:32 +08:00
|
|
|
#install(FILES ${lib_device_hdrs}
|
2011-06-29 00:02:09 +08:00
|
|
|
# DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}/device
|
2010-12-07 00:37:32 +08:00
|
|
|
# COMPONENT main)
|
|
|
|
|
2011-02-18 20:23:18 +08:00
|
|
|
|
|
|
|
################################################################################################################
|
|
|
|
################################ GPU Module Tests #####################################################
|
|
|
|
################################################################################################################
|
|
|
|
|
2011-02-16 19:38:58 +08:00
|
|
|
# Test files processing is in the separated directory to avoid 'Src' source
|
|
|
|
# filter creation in Visual Studio
|
2011-04-11 22:47:06 +08:00
|
|
|
if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test)
|
2011-02-18 20:23:18 +08:00
|
|
|
set(the_test_target "opencv_test_${name}")
|
2011-02-18 15:43:15 +08:00
|
|
|
|
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
|
|
|
|
set(test_deps opencv_${name} opencv_ts opencv_highgui opencv_calib3d ${DEPS})
|
|
|
|
foreach(d ${test_deps})
|
|
|
|
if(${d} MATCHES "opencv_")
|
2011-07-25 03:22:58 +08:00
|
|
|
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d})
|
|
|
|
include_directories("${d_dir}/include")
|
2011-02-18 15:43:15 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
file(GLOB test_srcs "test/*.cpp")
|
|
|
|
file(GLOB test_hdrs "test/*.h*")
|
2011-02-18 20:23:18 +08:00
|
|
|
|
|
|
|
source_group("Src" FILES ${test_hdrs} ${test_srcs})
|
2011-02-18 15:43:15 +08:00
|
|
|
if(HAVE_CUDA)
|
2011-06-15 16:05:34 +08:00
|
|
|
include_directories(${CUDA_INCLUDE_DIRS} ${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia ${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core ${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/NPP_staging)
|
|
|
|
|
|
|
|
file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.h*")
|
|
|
|
source_group("Src\\NVidia" FILES ${nvidia})
|
2011-02-18 15:43:15 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2011-02-18 20:23:18 +08:00
|
|
|
add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia})
|
2011-02-18 15:43:15 +08:00
|
|
|
|
2011-07-25 03:22:58 +08:00
|
|
|
add_opencv_precompiled_headers(${the_test_target})
|
2011-02-18 15:43:15 +08:00
|
|
|
|
|
|
|
# Additional target properties
|
2011-02-18 20:23:18 +08:00
|
|
|
set_target_properties(${the_test_target} PROPERTIES
|
2011-02-18 15:43:15 +08:00
|
|
|
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
2011-07-07 19:43:21 +08:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
|
2011-02-18 15:43:15 +08:00
|
|
|
)
|
2011-05-11 21:37:20 +08:00
|
|
|
|
2011-05-17 17:40:06 +08:00
|
|
|
if(ENABLE_SOLUTION_FOLDERS)
|
2011-05-11 21:37:20 +08:00
|
|
|
set_target_properties(${the_test_target} PROPERTIES FOLDER "tests")
|
2011-07-25 03:22:58 +08:00
|
|
|
endif()
|
2011-02-18 15:43:15 +08:00
|
|
|
|
2011-02-18 20:23:18 +08:00
|
|
|
add_dependencies(${the_test_target} ${test_deps})
|
2011-02-18 15:43:15 +08:00
|
|
|
|
|
|
|
# Add the required libraries for linking:
|
2011-02-18 20:23:18 +08:00
|
|
|
target_link_libraries(${the_test_target} ${OPENCV_LINKER_LIBS} ${test_deps})
|
2011-02-18 15:43:15 +08:00
|
|
|
|
|
|
|
enable_testing()
|
2011-02-18 20:23:18 +08:00
|
|
|
get_target_property(LOC ${the_test_target} LOCATION)
|
|
|
|
add_test(${the_test_target} "${LOC}")
|
2011-02-18 15:43:15 +08:00
|
|
|
|
2011-06-23 20:00:09 +08:00
|
|
|
#if(WIN32)
|
|
|
|
# install(TARGETS ${the_test_target} RUNTIME DESTINATION bin COMPONENT main)
|
|
|
|
#endif()
|
2011-02-21 18:58:05 +08:00
|
|
|
endif()
|
2011-09-07 21:16:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
define_opencv_perf_test(${name})
|