mirror of https://github.com/opencv/opencv.git
parent
98d663e7e0
commit
926a6bba00
40 changed files with 1135 additions and 1819 deletions
@ -1,236 +0,0 @@ |
||||
set(name "gpu") |
||||
|
||||
set(the_target "opencv_${name}") |
||||
project(${the_target}) |
||||
|
||||
set(DEPS "opencv_core" "opencv_imgproc" "opencv_objdetect" "opencv_features2d" "opencv_flann" "opencv_calib3d") #"opencv_features2d" "opencv_flann" "opencv_objdetect" - only headers needed |
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} opencv_gpu) |
||||
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" |
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/cuda" |
||||
"${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*") |
||||
source_group("Device" FILES ${lib_device_hdrs}) |
||||
|
||||
if (HAVE_CUDA) |
||||
file(GLOB_RECURSE ncv_srcs "src/nvidia/*.cpp") |
||||
file(GLOB_RECURSE ncv_cuda "src/nvidia/*.cu") |
||||
file(GLOB_RECURSE ncv_hdrs "src/nvidia/*.hpp" "src/nvidia/*.h") |
||||
|
||||
source_group("Src\\NVidia" FILES ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda}) |
||||
include_directories("src/nvidia/core" "src/nvidia/NPP_staging") |
||||
endif() |
||||
|
||||
if (HAVE_CUDA) |
||||
get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH) |
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp}) |
||||
find_package(NPP 3.2.16 REQUIRED) |
||||
message(STATUS "NPP detected: " ${NPP_VERSION}) |
||||
|
||||
include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_NPP_INCLUDES}) |
||||
|
||||
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-;") |
||||
|
||||
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}") |
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408") |
||||
|
||||
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() |
||||
|
||||
if (OPENCV_BUILD_SHARED_LIB) |
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-DCVAPI_EXPORTS") |
||||
endif() |
||||
|
||||
CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda}) |
||||
#CUDA_BUILD_CLEAN_TARGET() |
||||
endif() |
||||
|
||||
foreach(d ${DEPS}) |
||||
if(${d} MATCHES "opencv_") |
||||
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d}) |
||||
include_directories("${d_dir}/include") |
||||
endif() |
||||
endforeach() |
||||
|
||||
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${lib_device_hdrs} ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda} ${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*") |
||||
set(${the_target}_pch "src/precomp.cpp") |
||||
endif() |
||||
add_native_precompiled_header(${the_target} ${pch_header}) |
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles") |
||||
add_precompiled_header(${the_target} ${pch_header}) |
||||
endif() |
||||
endif() |
||||
|
||||
# For dynamic link numbering convenions |
||||
set_target_properties(${the_target} PROPERTIES |
||||
VERSION ${OPENCV_VERSION} |
||||
SOVERSION ${OPENCV_SOVERSION} |
||||
OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}" |
||||
) |
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS) |
||||
set_target_properties(${the_target} PROPERTIES FOLDER "modules") |
||||
endif() |
||||
|
||||
if (OPENCV_BUILD_SHARED_LIB) |
||||
if (MSVC) |
||||
set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS) |
||||
else() |
||||
add_definitions(-DCVAPI_EXPORTS) |
||||
endif() |
||||
endif() |
||||
|
||||
# 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: |
||||
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} ) |
||||
|
||||
if (HAVE_CUDA) |
||||
target_link_libraries(${the_target} ${CUDA_LIBRARIES} ${CUDA_NPP_LIBRARIES}) |
||||
CUDA_ADD_CUFFT_TO_TARGET(${the_target}) |
||||
endif() |
||||
|
||||
if(MSVC) |
||||
if(CMAKE_CROSSCOMPILING) |
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk") |
||||
endif() |
||||
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") |
||||
endif() |
||||
|
||||
# Dependencies of this target: |
||||
add_dependencies(${the_target} ${DEPS}) |
||||
|
||||
install(TARGETS ${the_target} |
||||
RUNTIME DESTINATION bin COMPONENT main |
||||
LIBRARY DESTINATION lib COMPONENT main |
||||
ARCHIVE DESTINATION lib COMPONENT main) |
||||
|
||||
install(FILES ${lib_hdrs} |
||||
DESTINATION include/opencv2/${name} |
||||
COMPONENT main) |
||||
|
||||
install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp |
||||
DESTINATION include/opencv2/${name} |
||||
COMPONENT main) |
||||
|
||||
#install(FILES ${lib_device_hdrs} |
||||
# DESTINATION include/opencv2/${name}/device |
||||
# COMPONENT main) |
||||
|
||||
|
||||
################################################################################################################ |
||||
################################ GPU Module Tests ##################################################### |
||||
################################################################################################################ |
||||
|
||||
# Test files processing is in the separated directory to avoid 'Src' source |
||||
# filter creation in Visual Studio |
||||
if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test) |
||||
set(the_test_target "opencv_test_${name}") |
||||
|
||||
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_") |
||||
if(${d} MATCHES "opencv_lapack") |
||||
else() |
||||
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d}) |
||||
include_directories("${d_dir}/include") |
||||
endif() |
||||
endif() |
||||
endforeach() |
||||
|
||||
file(GLOB test_srcs "test/*.cpp") |
||||
file(GLOB test_hdrs "test/*.h*") |
||||
|
||||
source_group("Src" FILES ${test_hdrs} ${test_srcs}) |
||||
if(HAVE_CUDA) |
||||
include_directories(${CUDA_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/NPP_staging) |
||||
|
||||
file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.h*") |
||||
source_group("Src\\NVidia" FILES ${nvidia}) |
||||
endif() |
||||
|
||||
|
||||
add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia}) |
||||
|
||||
if(PCHSupport_FOUND) |
||||
set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/test/test_precomp.hpp) |
||||
if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*") |
||||
if(${CMAKE_GENERATOR} MATCHES "Visual*") |
||||
set(${the_test_target}_pch "test/test_precomp.cpp") |
||||
endif() |
||||
add_native_precompiled_header(${the_test_target} ${pch_header}) |
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles") |
||||
add_precompiled_header(${the_test_target} ${pch_header}) |
||||
endif() |
||||
endif() |
||||
|
||||
# Additional target properties |
||||
set_target_properties(${the_test_target} PROPERTIES |
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" |
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/" |
||||
) |
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS) |
||||
set_target_properties(${the_test_target} PROPERTIES FOLDER "tests") |
||||
endif() |
||||
|
||||
add_dependencies(${the_test_target} ${test_deps}) |
||||
|
||||
# Add the required libraries for linking: |
||||
target_link_libraries(${the_test_target} ${OPENCV_LINKER_LIBS} ${test_deps}) |
||||
|
||||
enable_testing() |
||||
get_target_property(LOC ${the_test_target} LOCATION) |
||||
add_test(${the_test_target} "${LOC}") |
||||
|
||||
if(WIN32) |
||||
install(TARGETS ${the_test_target} RUNTIME DESTINATION bin COMPONENT main) |
||||
endif() |
||||
endif() |
@ -1,240 +0,0 @@ |
||||
set(name "gpu") |
||||
|
||||
set(the_target "opencv_${name}") |
||||
project(${the_target}) |
||||
|
||||
set(DEPS "opencv_core" "opencv_imgproc" "opencv_objdetect" "opencv_features2d" "opencv_flann" "opencv_calib3d") #"opencv_features2d" "opencv_flann" "opencv_objdetect" - only headers needed |
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} opencv_gpu) |
||||
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" |
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/cuda" |
||||
"${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*") |
||||
source_group("Device" FILES ${lib_device_hdrs}) |
||||
|
||||
if (HAVE_CUDA) |
||||
file(GLOB_RECURSE ncv_srcs "src/nvidia/*.cpp") |
||||
file(GLOB_RECURSE ncv_cuda "src/nvidia/*.cu") |
||||
file(GLOB_RECURSE ncv_hdrs "src/nvidia/*.hpp" "src/nvidia/*.h") |
||||
|
||||
source_group("Src\\NVidia" FILES ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda}) |
||||
include_directories("src/nvidia/core" "src/nvidia/NPP_staging") |
||||
endif() |
||||
|
||||
if (HAVE_CUDA) |
||||
#get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH) |
||||
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp}) |
||||
#find_package(NPP 3.2.16 REQUIRED) |
||||
#message(STATUS "NPP detected: " ${NPP_VERSION}) |
||||
|
||||
include_directories(${CUDA_INCLUDE_DIRS}) |
||||
|
||||
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-;") |
||||
|
||||
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}") |
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408") |
||||
|
||||
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() |
||||
|
||||
if (OPENCV_BUILD_SHARED_LIB) |
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-DCVAPI_EXPORTS") |
||||
endif() |
||||
|
||||
CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda}) |
||||
#CUDA_BUILD_CLEAN_TARGET() |
||||
endif() |
||||
|
||||
foreach(d ${DEPS}) |
||||
if(${d} MATCHES "opencv_") |
||||
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d}) |
||||
include_directories("${d_dir}/include") |
||||
endif() |
||||
endforeach() |
||||
|
||||
add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${lib_device_hdrs} ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda} ${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*") |
||||
set(${the_target}_pch "src/precomp.cpp") |
||||
endif() |
||||
add_native_precompiled_header(${the_target} ${pch_header}) |
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles") |
||||
add_precompiled_header(${the_target} ${pch_header}) |
||||
endif() |
||||
endif() |
||||
|
||||
# For dynamic link numbering convenions |
||||
set_target_properties(${the_target} PROPERTIES |
||||
VERSION ${OPENCV_VERSION} |
||||
SOVERSION ${OPENCV_SOVERSION} |
||||
OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}" |
||||
) |
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS) |
||||
set_target_properties(${the_target} PROPERTIES FOLDER "modules") |
||||
endif() |
||||
|
||||
if (OPENCV_BUILD_SHARED_LIB) |
||||
if (MSVC) |
||||
set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS) |
||||
else() |
||||
add_definitions(-DCVAPI_EXPORTS) |
||||
endif() |
||||
endif() |
||||
|
||||
# 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: |
||||
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} ) |
||||
|
||||
if (HAVE_CUDA) |
||||
target_link_libraries(${the_target} ${CUDA_LIBRARIES}) |
||||
CUDA_ADD_CUFFT_TO_TARGET(${the_target}) |
||||
|
||||
unset(CUDA_npp_LIBRARY CACHE) |
||||
find_cuda_helper_libs(npp) |
||||
target_link_libraries(${the_target} ${CUDA_npp_LIBRARY}) |
||||
endif() |
||||
|
||||
if(MSVC) |
||||
if(CMAKE_CROSSCOMPILING) |
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk") |
||||
endif() |
||||
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") |
||||
endif() |
||||
|
||||
# Dependencies of this target: |
||||
add_dependencies(${the_target} ${DEPS}) |
||||
|
||||
install(TARGETS ${the_target} |
||||
RUNTIME DESTINATION bin COMPONENT main |
||||
LIBRARY DESTINATION lib COMPONENT main |
||||
ARCHIVE DESTINATION lib COMPONENT main) |
||||
|
||||
install(FILES ${lib_hdrs} |
||||
DESTINATION include/opencv2/${name} |
||||
COMPONENT main) |
||||
|
||||
install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp |
||||
DESTINATION include/opencv2/${name} |
||||
COMPONENT main) |
||||
|
||||
#install(FILES ${lib_device_hdrs} |
||||
# DESTINATION include/opencv2/${name}/device |
||||
# COMPONENT main) |
||||
|
||||
|
||||
################################################################################################################ |
||||
################################ GPU Module Tests ##################################################### |
||||
################################################################################################################ |
||||
|
||||
# Test files processing is in the separated directory to avoid 'Src' source |
||||
# filter creation in Visual Studio |
||||
if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test) |
||||
set(the_test_target "opencv_test_${name}") |
||||
|
||||
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_") |
||||
if(${d} MATCHES "opencv_lapack") |
||||
else() |
||||
string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d}) |
||||
include_directories("${d_dir}/include") |
||||
endif() |
||||
endif() |
||||
endforeach() |
||||
|
||||
file(GLOB test_srcs "test/*.cpp") |
||||
file(GLOB test_hdrs "test/*.h*") |
||||
|
||||
source_group("Src" FILES ${test_hdrs} ${test_srcs}) |
||||
if(HAVE_CUDA) |
||||
include_directories(${CUDA_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/NPP_staging) |
||||
|
||||
file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.h*") |
||||
source_group("Src\\NVidia" FILES ${nvidia}) |
||||
endif() |
||||
|
||||
|
||||
add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia}) |
||||
|
||||
if(PCHSupport_FOUND) |
||||
set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/test/test_precomp.hpp) |
||||
if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*") |
||||
if(${CMAKE_GENERATOR} MATCHES "Visual*") |
||||
set(${the_test_target}_pch "test/test_precomp.cpp") |
||||
endif() |
||||
add_native_precompiled_header(${the_test_target} ${pch_header}) |
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles") |
||||
add_precompiled_header(${the_test_target} ${pch_header}) |
||||
endif() |
||||
endif() |
||||
|
||||
# Additional target properties |
||||
set_target_properties(${the_test_target} PROPERTIES |
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" |
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/" |
||||
) |
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS) |
||||
set_target_properties(${the_test_target} PROPERTIES FOLDER "tests") |
||||
endif() |
||||
|
||||
add_dependencies(${the_test_target} ${test_deps}) |
||||
|
||||
# Add the required libraries for linking: |
||||
target_link_libraries(${the_test_target} ${OPENCV_LINKER_LIBS} ${test_deps}) |
||||
|
||||
enable_testing() |
||||
get_target_property(LOC ${the_test_target} LOCATION) |
||||
add_test(${the_test_target} "${LOC}") |
||||
|
||||
if(WIN32) |
||||
install(TARGETS ${the_test_target} RUNTIME DESTINATION bin COMPONENT main) |
||||
endif() |
||||
endif() |
@ -1,125 +0,0 @@ |
||||
############################################################################### |
||||
# |
||||
# FindNPP.cmake |
||||
# |
||||
# CUDA_NPP_LIBRARY_ROOT_DIR -- Path to the NPP dorectory. |
||||
# CUDA_NPP_INCLUDES -- NPP Include directories. |
||||
# CUDA_NPP_LIBRARIES -- NPP libraries. |
||||
# NPP_VERSION -- NPP version in format "major.minor.build". |
||||
# |
||||
# If not found automatically, please set CUDA_NPP_LIBRARY_ROOT_DIR |
||||
# in CMake or set enviroment varivabe $CUDA_NPP_ROOT |
||||
# |
||||
# Author: Anatoly Baksheev, Itseez Ltd. |
||||
# |
||||
# The MIT License |
||||
# |
||||
# License for the specific language governing rights and limitations under |
||||
# Permission is hereby granted, free of charge, to any person obtaining a |
||||
# copy of this software and associated documentation files (the "Software"), |
||||
# to deal in the Software without restriction, including without limitation |
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
# and/or sell copies of the Software, and to permit persons to whom the |
||||
# Software is furnished to do so, subject to the following conditions: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
# DEALINGS IN THE SOFTWARE. |
||||
# |
||||
############################################################################### |
||||
|
||||
cmake_policy(PUSH) |
||||
cmake_minimum_required(VERSION 2.8.0) |
||||
cmake_policy(POP) |
||||
|
||||
if(NOT "${CUDA_NPP_LIBRARY_ROOT_DIR}" STREQUAL "${CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL}") |
||||
unset(CUDA_NPP_INCLUDES CACHE) |
||||
unset(CUDA_NPP_LIBRARIES CACHE) |
||||
endif() |
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
if (UNIX OR APPLE) |
||||
set(NPP_SUFFIX "32") |
||||
else() |
||||
set(NPP_SUFFIX "-mt") |
||||
endif() |
||||
else(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
if (UNIX OR APPLE) |
||||
set(NPP_SUFFIX "64") |
||||
else() |
||||
set(NPP_SUFFIX "-mt-x64") |
||||
endif() |
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
|
||||
if(NOT CUDA_NPP_LIBRARY_ROOT_DIR OR CUDA_NPP_LIBRARY_ROOT_DIR STREQUAL "") |
||||
unset(CUDA_NPP_LIBRARY_ROOT_DIR CACHE) |
||||
find_path(CUDA_NPP_LIBRARY_ROOT_DIR "common/npp/include/npp.h" PATHS ENV CUDA_NPP_ROOT DOC "NPP root directory.") |
||||
MESSAGE(STATUS "NPP root directory: " ${CUDA_NPP_LIBRARY_ROOT_DIR}) |
||||
endif() |
||||
|
||||
# Search includes in our own paths. |
||||
find_path(CUDA_NPP_INCLUDES npp.h PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}/common/npp/include") |
||||
# Search default search paths, after we search our own set of paths. |
||||
find_path(CUDA_NPP_INCLUDES device_functions.h) |
||||
mark_as_advanced(CUDA_NPP_INCLUDES) |
||||
|
||||
# Find NPP library |
||||
find_library(CUDA_NPP_LIBRARIES |
||||
NAMES "npp" "npp${NPP_SUFFIX}" "libnpp${NPP_SUFFIX}" |
||||
PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}" |
||||
PATH_SUFFIXES "common/lib" "common/npp/lib" |
||||
DOC "NPP library" |
||||
) |
||||
|
||||
# Search default search paths, after we search our own set of paths. |
||||
find_library(CUDA_NPP_LIBRARIES NAMES npp${NPP_SUFFIX} libnpp${NPP_SUFFIX} DOC "NPP library") |
||||
mark_as_advanced(CUDA_NPP_LIBRARIES) |
||||
|
||||
if(EXISTS ${CUDA_NPP_INCLUDES}/nppversion.h) |
||||
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*") |
||||
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*") |
||||
file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*") |
||||
|
||||
string( REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${npp_major}) |
||||
string( REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${npp_minor}) |
||||
string( REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${npp_build}) |
||||
|
||||
string( REGEX MATCH "[0-9]+" npp_major ${npp_major} ) |
||||
string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} ) |
||||
string( REGEX MATCH "[0-9]+" npp_build ${npp_build} ) |
||||
set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") |
||||
endif() |
||||
|
||||
if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h) |
||||
set(CUDA_NPP_FOUND FALSE) |
||||
message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $CUDA_NPP_ROOT.") |
||||
endif() |
||||
|
||||
include( FindPackageHandleStandardArgs ) |
||||
find_package_handle_standard_args( NPP |
||||
REQUIRED_VARS |
||||
CUDA_NPP_INCLUDES |
||||
CUDA_NPP_LIBRARIES |
||||
#Need cmake 2.8.3 to uncomment this. |
||||
#VERSION_VAR |
||||
NPP_VERSION) |
||||
|
||||
if(APPLE) |
||||
# We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath. |
||||
get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH) |
||||
if(_cuda_path_to_npp) |
||||
list(APPEND CUDA_NPP_LIBRARIES "-Wl,-rpath,${_cuda_path_to_npp}") |
||||
endif() |
||||
endif() |
||||
|
||||
set(CUDA_NPP_FOUND TRUE) |
||||
set(CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL "${CUDA_NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_NPP_LIBRARY_ROOT_DIR was set successfully." FORCE) |
||||
|
||||
|
Loading…
Reference in new issue