Global CMake reorganization:

[~] Automatically tracked dependencies between modules
 [+] Support for optional module dependencies
 [+] Options to choose modules to build
 [~] Removed hardcoded modules lists from OpenCVConfig.cmake, opencv.pc and OpenCV.mk
 [+] Added COMPONENTS support for FIND_PACKAGE(OpenCV)
 [~] haartraining and traincascade are moved outside of modules folder since they aren't the modules
pull/13383/head
Andrey Kamaev 13 years ago
parent ada9158521
commit 984eb99428
  1. 1194
      CMakeLists.txt
  2. 13
      android/android.toolchain.cmake
  3. 2
      apps/CMakeLists.txt
  4. 78
      apps/haartraining/CMakeLists.txt
  5. 0
      apps/haartraining/_cvcommon.h
  6. 0
      apps/haartraining/_cvhaartraining.h
  7. 0
      apps/haartraining/createsamples.cpp
  8. 0
      apps/haartraining/cvboost.cpp
  9. 0
      apps/haartraining/cvclassifier.h
  10. 0
      apps/haartraining/cvcommon.cpp
  11. 0
      apps/haartraining/cvhaarclassifier.cpp
  12. 0
      apps/haartraining/cvhaartraining.cpp
  13. 0
      apps/haartraining/cvhaartraining.h
  14. 0
      apps/haartraining/cvsamples.cpp
  15. 0
      apps/haartraining/haartraining.cpp
  16. 0
      apps/haartraining/performance.cpp
  17. 41
      apps/traincascade/CMakeLists.txt
  18. 0
      apps/traincascade/HOGfeatures.cpp
  19. 0
      apps/traincascade/HOGfeatures.h
  20. 0
      apps/traincascade/boost.cpp
  21. 0
      apps/traincascade/boost.h
  22. 0
      apps/traincascade/cascadeclassifier.cpp
  23. 0
      apps/traincascade/cascadeclassifier.h
  24. 0
      apps/traincascade/features.cpp
  25. 0
      apps/traincascade/haarfeatures.cpp
  26. 0
      apps/traincascade/haarfeatures.h
  27. 0
      apps/traincascade/imagestorage.cpp
  28. 0
      apps/traincascade/imagestorage.h
  29. 0
      apps/traincascade/lbpfeatures.cpp
  30. 0
      apps/traincascade/lbpfeatures.h
  31. 0
      apps/traincascade/traincascade.cpp
  32. 0
      apps/traincascade/traincascade_features.h
  33. 65
      cmake/OpenCVCRTLinkage.cmake
  34. 190
      cmake/OpenCVCompilerOptions.cmake
  35. 91
      cmake/OpenCVDetectAndroidSDK.cmake
  36. 16
      cmake/OpenCVDetectApacheAnt.cmake
  37. 88
      cmake/OpenCVDetectCUDA.cmake
  38. 76
      cmake/OpenCVDetectCXXCompiler.cmake
  39. 59
      cmake/OpenCVDetectPython.cmake
  40. 63
      cmake/OpenCVDetectTBB.cmake
  41. 53
      cmake/OpenCVExtraTargets.cmake
  42. 83
      cmake/OpenCVGenAndroidMK.cmake
  43. 130
      cmake/OpenCVGenConfig.cmake
  44. 36
      cmake/OpenCVGenHeaders.cmake
  45. 75
      cmake/OpenCVGenPkgconfig.cmake
  46. 850
      cmake/OpenCVModule.cmake
  47. 93
      cmake/OpenCVUtils.cmake
  48. 28
      cmake/OpenCVVersion.cmake
  49. 36
      cmake/templates/OpenCV.mk.in
  50. 294
      cmake/templates/OpenCVConfig.cmake.in
  51. 13
      cmake/templates/opencv.pc.cmake.in
  52. 9
      cmake/templates/opencv_modules.hpp.in
  53. 11
      modules/CMakeLists.txt
  54. 38
      modules/androidcamera/CMakeLists.txt
  55. 3
      modules/calib3d/CMakeLists.txt
  56. 2
      modules/contrib/CMakeLists.txt
  57. 1
      modules/contrib/src/featuretracker.cpp
  58. 44
      modules/core/CMakeLists.txt
  59. 2
      modules/core/include/opencv2/core/version.hpp
  60. 3
      modules/features2d/CMakeLists.txt
  61. 3
      modules/flann/CMakeLists.txt
  62. 224
      modules/gpu/CMakeLists.txt
  63. 62
      modules/highgui/CMakeLists.txt
  64. 2
      modules/highgui/src/cap_libv4l.cpp
  65. 3
      modules/imgproc/CMakeLists.txt
  66. 36
      modules/java/CMakeLists.txt
  67. 2
      modules/legacy/CMakeLists.txt
  68. 3
      modules/ml/CMakeLists.txt
  69. 3
      modules/objdetect/CMakeLists.txt
  70. 14
      modules/python/CMakeLists.txt
  71. 12
      modules/stitching/CMakeLists.txt
  72. 5
      modules/stitching/include/opencv2/stitching/detail/matchers.hpp
  73. 3
      modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp
  74. 5
      modules/stitching/include/opencv2/stitching/detail/warpers.hpp
  75. 2
      modules/stitching/include/opencv2/stitching/warpers.hpp
  76. 6
      modules/stitching/src/blenders.cpp
  77. 3
      modules/stitching/src/exposure_compensate.cpp
  78. 10
      modules/stitching/src/matchers.cpp
  79. 5
      modules/stitching/src/precomp.hpp
  80. 2
      modules/stitching/src/seam_finders.cpp
  81. 2
      modules/stitching/src/stitcher.cpp
  82. 2
      modules/stitching/src/warpers.cpp
  83. 51
      modules/traincascade/CMakeLists.txt
  84. 34
      modules/ts/CMakeLists.txt
  85. 3
      modules/video/CMakeLists.txt
  86. 14
      samples/CMakeLists.txt
  87. 57
      samples/android/CMakeLists.txt
  88. 100
      samples/c/CMakeLists.txt
  89. 116
      samples/cpp/CMakeLists.txt
  90. 9
      samples/cpp/hybridtrackingsample.cpp
  91. 5
      samples/cpp/image.cpp
  92. 9
      samples/cpp/stitching_detailed.cpp
  93. 118
      samples/gpu/CMakeLists.txt
  94. 2
      samples/gpu/cascadeclassifier_nvidia_api.cpp
  95. 1
      samples/gpu/opticalflow_nvidia_api.cpp
  96. 23
      samples/gpu/performance/CMakeLists.txt

File diff suppressed because it is too large Load Diff

@ -155,6 +155,7 @@
# [+] added special check for cygwin
# [+] filtered out hidden files (starting with .) while globbing inside NDK
# [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
# [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
# ------------------------------------------------------------------------------
# this one is important
@ -890,6 +891,18 @@ macro( find_host_program )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()
macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR )
if( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" )
set( ${VAR} "armeabi" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" )
set( ${VAR} "armeabi-v7a" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
set( ${VAR} "x86" )
else()
set( ${VAR} "unknown" )
endif()
endmacro()
set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES )
if( ANDROID_SET_OBSOLETE_VARIABLES )

@ -0,0 +1,2 @@
add_subdirectory(haartraining)
add_subdirectory(traincascade)

@ -1,61 +1,53 @@
if(IOS)
return()
if(IOS OR ANDROID)
return()
endif()
SET(OPENCV_HAARTRAINING_DEPS opencv_core opencv_imgproc opencv_highgui opencv_objdetect opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
ocv_check_dependencies(${OPENCV_HAARTRAINING_DEPS})
if(NOT OCV_DEPENDENCIES_FOUND)
return()
endif()
project(haartraining)
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}"
"${OpenCV_SOURCE_DIR}/modules/core/include"
"${OpenCV_SOURCE_DIR}/modules/imgproc/include"
"${OpenCV_SOURCE_DIR}/modules/objdetect/include"
"${OpenCV_SOURCE_DIR}/modules/ml/include"
"${OpenCV_SOURCE_DIR}/modules/highgui/include"
"${OpenCV_SOURCE_DIR}/modules/video/include"
"${OpenCV_SOURCE_DIR}/modules/features2d/include"
"${OpenCV_SOURCE_DIR}/modules/flann/include"
"${OpenCV_SOURCE_DIR}/modules/calib3d/include"
"${OpenCV_SOURCE_DIR}/modules/legacy/include"
)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules(${OPENCV_HAARTRAINING_DEPS})
if(WIN32)
link_directories(${OpenCV_SOURCE_DIR}/lib ${OpenCV_SOURCE_DIR}/bin ${CMAKE_CURRENT_BINARY_DIR})
link_directories(${CMAKE_CURRENT_BINARY_DIR})
endif()
set(haartraining_libs opencv_core opencv_imgproc opencv_highgui opencv_objdetect opencv_calib3d opencv_haartraining_engine)
link_libraries(${haartraining_libs})
link_libraries(${OPENCV_HAARTRAINING_DEPS} opencv_haartraining_engine)
# -----------------------------------------------------------
# Library
# -----------------------------------------------------------
set(cvhaartraining_lib_src
_cvcommon.h
cvclassifier.h
_cvhaartraining.h
cvhaartraining.h
cvboost.cpp
cvcommon.cpp
cvhaarclassifier.cpp
cvhaartraining.cpp
cvsamples.cpp
)
_cvcommon.h
cvclassifier.h
_cvhaartraining.h
cvhaartraining.h
cvboost.cpp
cvcommon.cpp
cvhaarclassifier.cpp
cvhaartraining.cpp
cvsamples.cpp
)
add_library(opencv_haartraining_engine STATIC ${cvhaartraining_lib_src})
set_target_properties(opencv_haartraining_engine PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
)
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
)
if(NOT ANDROID)
# -----------------------------------------------------------
# haartraining
# -----------------------------------------------------------
add_executable(opencv_haartraining cvhaartraining.h haartraining.cpp)
add_dependencies(opencv_haartraining ${haartraining_libs})
set_target_properties(opencv_haartraining PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
OUTPUT_NAME "opencv_haartraining")
@ -65,7 +57,6 @@ set_target_properties(opencv_haartraining PROPERTIES
# -----------------------------------------------------------
add_executable(opencv_createsamples cvhaartraining.h createsamples.cpp)
add_dependencies(opencv_createsamples ${haartraining_libs})
set_target_properties(opencv_createsamples PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
OUTPUT_NAME "opencv_createsamples")
@ -74,7 +65,6 @@ set_target_properties(opencv_createsamples PROPERTIES
# performance
# -----------------------------------------------------------
add_executable(opencv_performance performance.cpp)
add_dependencies(opencv_performance ${haartraining_libs})
set_target_properties(opencv_performance PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
OUTPUT_NAME "opencv_performance")
@ -87,12 +77,10 @@ install(TARGETS opencv_haartraining RUNTIME DESTINATION bin COMPONENT main)
install(TARGETS opencv_createsamples RUNTIME DESTINATION bin COMPONENT main)
install(TARGETS opencv_performance RUNTIME DESTINATION bin COMPONENT main)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_performance PROPERTIES FOLDER "applications")
set_target_properties(opencv_createsamples PROPERTIES FOLDER "applications")
set_target_properties(opencv_haartraining PROPERTIES FOLDER "applications")
set_target_properties(opencv_haartraining_engine PROPERTIES FOLDER "applications")
endif()
set_target_properties(opencv_performance PROPERTIES FOLDER "applications")
set_target_properties(opencv_createsamples PROPERTIES FOLDER "applications")
set_target_properties(opencv_haartraining PROPERTIES FOLDER "applications")
set_target_properties(opencv_haartraining_engine PROPERTIES FOLDER "applications")
endif()

@ -0,0 +1,41 @@
if(IOS OR ANDROID)
return()
endif()
SET(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS})
if(NOT OCV_DEPENDENCIES_FOUND)
return()
endif()
project(traincascade)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
ocv_include_modules(${OPENCV_TRAINCASCADE_DEPS})
set(traincascade_files traincascade.cpp
cascadeclassifier.cpp cascadeclassifier.h
boost.cpp boost.h features.cpp traincascade_features.h
haarfeatures.cpp haarfeatures.h
lbpfeatures.cpp lbpfeatures.h
HOGfeatures.cpp HOGfeatures.h
imagestorage.cpp imagestorage.h)
set(the_target opencv_traincascade)
add_executable(${the_target} ${traincascade_files})
target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS} opencv_haartraining_engine)
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
OUTPUT_NAME "opencv_traincascade")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
endif()
install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)

@ -0,0 +1,65 @@
if(NOT MSVC)
message(FATAL_ERROR "CRT options are available only for MSVC"
endif()
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
if(${flag_var} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
else()
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
endif()
if(${flag_var} MATCHES "/MTd")
string(REGEX REPLACE "/MTd" "/MDd" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
endif()
if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8 AND NOT ${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} LESS 8.6)
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${N} ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${N} ")
endif()
endif()
if(NOT BUILD_WITH_DEBUG_INFO)
string(REPLACE "/debug" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/DEBUG" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL:YES" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/debug" "" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/DEBUG" "" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL:YES" "/INCREMENTAL:NO" CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/debug" "" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/DEBUG" "" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL:YES" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL " "/INCREMENTAL:NO " CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
string(REPLACE "/Zi" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
endif()

@ -0,0 +1,190 @@
if (WIN32 AND CMAKE_GENERATOR MATCHES "(MinGW)|(MSYS)")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "")
endif()
set(OPENCV_EXTRA_C_FLAGS "")
set(OPENCV_EXTRA_C_FLAGS_RELEASE "")
set(OPENCV_EXTRA_C_FLAGS_DEBUG "")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "")
if(MSVC)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS")
# 64-bit portability warnings, in MSVC8
if(MSVC80)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /Wp64")
endif()
#if(MSVC90)
# set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /D _BIND_TO_CURRENT_CRT_VERSION=1 /D _BIND_TO_CURRENT_VCLIBS_VERSION=1")
#endif()
if(BUILD_WITH_DEBUG_INFO)
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE} /debug")
endif()
# Remove unreferenced functions: function level linking
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} /Gy")
if(BUILD_WITH_DEBUG_INFO)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /Zi")
endif()
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
# High level of warnings.
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wall")
# The -Wno-long-long is required in 64bit systems when including sytem headers.
if(X86_64)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Wno-long-long")
endif()
# We need pthread's
if(UNIX AND NOT ANDROID)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -pthread")
endif()
if(OPENCV_WARNINGS_ARE_ERRORS)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -Werror")
endif()
if(X86 AND NOT MINGW64 AND NOT X86_64 AND NOT APPLE)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -march=i686")
endif()
# Other optimizations
if(ENABLE_OMIT_FRAME_POINTER)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -fomit-frame-pointer")
else()
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -fno-omit-frame-pointer")
endif()
if(ENABLE_FAST_MATH)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -ffast-math")
endif()
if(ENABLE_POWERPC)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -mcpu=G3 -mtune=G5")
endif()
if(ENABLE_SSE)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -msse")
endif()
if(ENABLE_SSE2)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -msse2")
endif()
# SSE3 and further should be disabled under MingW because it generates compiler errors
if(NOT MINGW)
if(ENABLE_SSE3)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -msse3")
endif()
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 402)
set(HAVE_GCC43_OR_NEWER 1)
endif()
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 401)
set(HAVE_GCC42_OR_NEWER 1)
endif()
if(HAVE_GCC42_OR_NEWER OR APPLE)
if(ENABLE_SSSE3)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -mssse3")
endif()
if(HAVE_GCC43_OR_NEWER)
if(ENABLE_SSE41)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -msse4.1")
endif()
if(ENABLE_SSE42)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -msse4.2")
endif()
endif()
endif()
endif(NOT MINGW)
if(X86 OR X86_64)
if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -mfpmath=387")
endif()
endif()
# Profiling?
if(ENABLE_PROFILING)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -pg -g")
elseif(NOT APPLE)
# Remove unreferenced functions: function level linking
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} -ffunction-sections")
endif()
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} -DNDEBUG")
set(OPENCV_EXTRA_C_FLAGS_DEBUG "${OPENCV_EXTRA_C_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG")
if(BUILD_WITH_DEBUG_INFO)
set(OPENCV_EXTRA_C_FLAGS_DEBUG "${OPENCV_EXTRA_C_FLAGS_DEBUG} -ggdb3")
endif()
endif()
if(MSVC)
# 64-bit MSVC compiler uses SSE/SSE2 by default
if(NOT MSVC64)
if(ENABLE_SSE)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /arch:SSE")
endif()
if(ENABLE_SSE2)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /arch:SSE2")
endif()
endif()
if(ENABLE_SSE3)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /arch:SSE3")
endif()
if(ENABLE_SSE4_1)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /arch:SSE4.1")
endif()
if (ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1)
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE} /Oi")
endif()
endif()
# Extra link libs if the user selects building static libs:
if(NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
# Android does not need these settings because they are already set by toolchain file
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} stdc++)
set(OPENCV_EXTRA_C_FLAGS "-fPIC ${OPENCV_EXTRA_C_FLAGS}")
endif()
# Add user supplied extra options (optimization, etc...)
# ==========================================================
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options")
set(OPENCV_EXTRA_C_FLAGS_RELEASE "${OPENCV_EXTRA_C_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build")
set(OPENCV_EXTRA_C_FLAGS_DEBUG "${OPENCV_EXTRA_C_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "Extra linker flags for Release build")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build")
#combine all "extra" options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPENCV_EXTRA_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_C_FLAGS_DEBUG}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
if (WIN32 AND MSVC)
# avoid warnings from MSVC about overriding the /W* option
# we replace /W3 with /W4 only for C++ files,
# since all the 3rd-party libraries OpenCV uses are in C,
# and we do not care about their warnings.
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# allow extern "C" functions throw exceptions
string(REPLACE "/EHsc" "/EHsc-" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "/EHsc" "/EHsc-" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REPLACE "/EHsc" "/EHsc-" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/EHsc" "/EHsc-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/EHsc" "/EHsc-" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/EHsc" "/EHsc-" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/Zm1000" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()

@ -0,0 +1,91 @@
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
file(TO_CMAKE_PATH "$ENV{ANDROID_SDK}" ANDROID_SDK_ENV_PATH)
#find android SDK
find_host_program(ANDROID_EXECUTABLE
NAMES android.bat android
PATHS "${ANDROID_SDK_ENV_PATH}/tools/"
"${ProgramFiles_ENV_PATH}/Android/android-sdk/tools/"
"/opt/android-sdk/tools/"
"/opt/android-sdk-linux_x86/tools/"
"/opt/android-sdk-mac_x86/tools/"
"/opt/android-sdk-linux_86/tools/"
"/opt/android-sdk-mac_86/tools/"
)
if(ANDROID_EXECUTABLE)
message(STATUS " Found android tool: ${ANDROID_EXECUTABLE}")
get_filename_component(ANDROID_SDK_TOOLS_PATH "${ANDROID_EXECUTABLE}" PATH)
#read source.properties
if(EXISTS "${ANDROID_SDK_TOOLS_PATH}/source.properties")
file(STRINGS "${ANDROID_SDK_TOOLS_PATH}/source.properties" ANDROID_SDK_TOOLS_SOURCE_PROPERTIES_LINES REGEX "^[ ]*[^#].*$")
foreach(line ${ANDROID_SDK_TOOLS_SOURCE_PROPERTIES_LINES})
string(REPLACE "\\:" ":" line ${line})
string(REPLACE "=" ";" line ${line})
list(GET line 0 line_name)
list(GET line 1 line_value)
string(REPLACE "." "_" line_name ${line_name})
SET(ANDROID_TOOLS_${line_name} "${line_value}")
MARK_AS_ADVANCED(ANDROID_TOOLS_${line_name})
endforeach()
endif()
if(NOT ANDROID_TOOLS_Pkg_Revision)
SET(ANDROID_TOOLS_Pkg_Revision "Unknown")
MARK_AS_ADVANCED(ANDROID_TOOLS_Pkg_Revision)
endif()
if(NOT ANDROID_TOOLS_Pkg_Desc)
SET(ANDROID_TOOLS_Pkg_Desc "Android SDK Tools, revision ${ANDROID_TOOLS_Pkg_Revision}.")
if(NOT ANDROID_TOOLS_Pkg_Revision GREATER 11)
SET(ANDROID_TOOLS_Pkg_Desc "${ANDROID_TOOLS_Pkg_Desc} It is recommended to update your SDK tools to revision 12 or newer.")
endif()
MARK_AS_ADVANCED(ANDROID_TOOLS_Pkg_Desc)
endif()
#get installed targets
execute_process(COMMAND ${ANDROID_EXECUTABLE} list target
RESULT_VARIABLE ANDROID_PROCESS
OUTPUT_VARIABLE ANDROID_SDK_TARGETS_FULL
ERROR_VARIABLE ANDROID_PROCESS_ERRORS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX MATCHALL "(^|\n)id: [0-9]+ or \"([^\n]+[0-9+])\"(\n|$)" ANDROID_SDK_TARGETS_FULL "${ANDROID_SDK_TARGETS_FULL}")
SET(ANDROID_SDK_TARGETS "")
if(ANDROID_PROCESS EQUAL 0)
foreach(line ${ANDROID_SDK_TARGETS_FULL})
string(REGEX REPLACE "(^|\n)id: [0-9]+ or \"([^\n]+[0-9+])\"(\n|$)" "\\2" line "${line}")
list(APPEND ANDROID_SDK_TARGETS "${line}")
endforeach()
endif()
# detect ANDROID_SDK_TARGET if no target is provided by user
if(NOT ANDROID_SDK_TARGET)
set(desired_android_target_level ${ANDROID_NATIVE_API_LEVEL})
if(desired_android_target_level LESS 8)
set(desired_android_target_level 8)
endif()
if(ANDROID_PROCESS EQUAL 0)
math(EXPR desired_android_target_level_1 "${desired_android_target_level}-1")
foreach(target ${ANDROID_SDK_TARGETS})
string(REGEX MATCH "[0-9]+$" target_level "${target}")
if(target_level GREATER desired_android_target_level_1)
set(ANDROID_SDK_TARGET "${target}")
break()
endif()
endforeach()
else()
set(ANDROID_SDK_TARGET android-${desired_android_target_level})
message(WARNING "Could not retrieve list of installed Android targets. Will try to use \"${ANDROID_SDK_TARGET}\" target")
endif()
endif(NOT ANDROID_SDK_TARGET)
SET(ANDROID_SDK_TARGET "${ANDROID_SDK_TARGET}" CACHE STRING "SDK target for Android tests and samples")
if(ANDROID_PROCESS EQUAL 0 AND CMAKE_VERSION VERSION_GREATER "2.8")
set_property( CACHE ANDROID_SDK_TARGET PROPERTY STRINGS ${ANDROID_SDK_TARGETS} )
endif()
string(REGEX MATCH "[0-9]+$" ANDROID_SDK_TARGET_LEVEL "${ANDROID_SDK_TARGET}")
endif(ANDROID_EXECUTABLE)

@ -0,0 +1,16 @@
file(TO_CMAKE_PATH "$ENV{ANT_DIR}" ANT_DIR_ENV_PATH)
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
find_host_program(ANT_EXECUTABLE NAMES ant.bat ant
PATHS "${ANT_DIR_ENV_PATH}/bin"
"${ProgramFiles_ENV_PATH}/apache-ant/bin"
)
if(ANT_EXECUTABLE)
execute_process(COMMAND ${ANT_EXECUTABLE} -version
OUTPUT_VARIABLE ANT_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" ANT_VERSION "${ANT_VERSION_FULL}")
message(STATUS " Found apache ant ${ANT_VERSION}: ${ANT_EXECUTABLE}")
endif()

@ -0,0 +1,88 @@
find_package(CUDA 4.0)
if(CUDA_FOUND)
set(HAVE_CUDA 1)
if(WITH_CUFFT)
set(HAVE_CUFFT 1)
endif()
if(WITH_CUBLAS)
set(HAVE_CUBLAS 1)
endif()
message(STATUS "CUDA detected: " ${CUDA_VERSION})
set(CUDA_ARCH_BIN "1.1 1.2 1.3 2.0 2.1(2.0)" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
set(CUDA_ARCH_PTX "2.0" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
string(REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}")
string(REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}")
# Ckeck if user specified 1.0 compute capability: we don't support it
string(REGEX MATCH "1.0" HAS_ARCH_10 "${CUDA_ARCH_BIN} ${CUDA_ARCH_PTX}")
set(CUDA_ARCH_BIN_OR_PTX_10 0)
if(NOT ${HAS_ARCH_10} STREQUAL "")
set(CUDA_ARCH_BIN_OR_PTX_10 1)
endif()
# NVCC flags to be set
set(NVCC_FLAGS_EXTRA "")
# These vars will be passed into the templates
set(OPENCV_CUDA_ARCH_BIN "")
set(OPENCV_CUDA_ARCH_PTX "")
set(OPENCV_CUDA_ARCH_FEATURES "")
# Tell NVCC to add binaries for the specified GPUs
string(REGEX MATCHALL "[0-9()]+" ARCH_LIST "${ARCH_BIN_NO_POINTS}")
foreach(ARCH IN LISTS ARCH_LIST)
if(ARCH MATCHES "([0-9]+)\\(([0-9]+)\\)")
# User explicitly specified PTX for the concrete BIN
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${CMAKE_MATCH_2},code=sm_${CMAKE_MATCH_1})
set(OPENCV_CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN} ${CMAKE_MATCH_1}")
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${CMAKE_MATCH_2}")
else()
# User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${ARCH},code=sm_${ARCH})
set(OPENCV_CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN} ${ARCH}")
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}")
endif()
endforeach()
# Tell NVCC to add PTX intermediate code for the specified architectures
string(REGEX MATCHALL "[0-9]+" ARCH_LIST "${ARCH_PTX_NO_POINTS}")
foreach(ARCH IN LISTS ARCH_LIST)
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${ARCH},code=compute_${ARCH})
set(OPENCV_CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX} ${ARCH}")
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}")
endforeach()
# These vars will be processed in other scripts
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${NVCC_FLAGS_EXTRA})
set(OpenCV_CUDA_CC "${NVCC_FLAGS_EXTRA}")
message(STATUS "CUDA NVCC target flags: ${CUDA_NVCC_FLAGS}")
macro(OCV_CUDA_COMPILE VAR)
if (BUILD_SHARED_LIBS)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCVAPI_EXPORTS)
endif()
if(UNIX OR APPLE)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fPIC)
endif()
if(APPLE)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fno-finite-math-only)
endif()
# we remove -ggdb3 flag as it leads to preprocessor errors when compiling CUDA files (CUDA 4.1)
set(CMAKE_CXX_FLAGS_DEBUG_ ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "-ggdb3" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
CUDA_COMPILE(${VAR} ${ARGN})
set(CMAKE_CXX_DEBUG_FLAGS ${CMAKE_CXX_FLAGS_DEBUG_})
endmacro()
else()
unset(CUDA_ARCH_BIN CACHE)
unset(CUDA_ARCH_PTX CACHE)
endif()

@ -0,0 +1,76 @@
# ----------------------------------------------------------------------------
# Detect Microsoft compiler:
# ----------------------------------------------------------------------------
if(CMAKE_CL_64)
set(MSVC64 1)
endif()
# ----------------------------------------------------------------------------
# Detect Intel ICC compiler -- for -fPIC in 3rdparty ( UNIX ONLY ):
# see include/opencv/cxtypes.h file for related ICC & CV_ICC defines.
# NOTE: The system needs to determine if the '-fPIC' option needs to be added
# for the 3rdparty static libs being compiled. The CMakeLists.txt files
# in 3rdparty use the CV_ICC definition being set here to determine if
# the -fPIC flag should be used.
# ----------------------------------------------------------------------------
if(UNIX)
if (__ICL)
set(CV_ICC __ICL)
elseif(__ICC)
set(CV_ICC __ICC)
elseif(__ECL)
set(CV_ICC __ECL)
elseif(__ECC)
set(CV_ICC __ECC)
elseif(__INTEL_COMPILER)
set(CV_ICC __INTEL_COMPILER)
elseif(CMAKE_C_COMPILER MATCHES "icc")
set(CV_ICC icc_matches_c_compiler)
endif()
endif()
if(MSVC AND CMAKE_C_COMPILER MATCHES "icc")
set(CV_ICC __INTEL_COMPILER_FOR_WINDOWS)
endif()
# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v
ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
# Look for the version number
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
# Split the three parts:
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")
if(WIN32)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_TARGET_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_OPENCV_GCC_TARGET_MACHINE MATCHES "64")
set(MINGW64 1)
endif()
endif()
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES amd64.*|x86_64.*)
set(X86_64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i686.*|i386.*|x86.*)
set(X86 1)
endif()

@ -0,0 +1,59 @@
find_host_package(PythonInterp)
find_host_package(PythonLibs)
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
set(PYTHONLIBS_FOUND ON)
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
ERROR_VARIABLE PYTHON_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_lib()"
RESULT_VARIABLE PYTHON_CVPY_PROCESS
OUTPUT_VARIABLE PYTHON_STD_PACKAGES_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages")
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.")
else() #debian based assumed, install to the dist-packages.
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.")
endif()
endif()
if(CMAKE_HOST_WIN32)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
endif()
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]"
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(PYTHON_NUMPY_PROCESS EQUAL 0)
set(PYTHON_USE_NUMPY 1)
add_definitions(-DPYTHON_USE_NUMPY=1)
include_directories(AFTER ${PYTHON_NUMPY_INCLUDE_DIRS})
message(STATUS " Use NumPy headers from: ${PYTHON_NUMPY_INCLUDE_DIRS}")
else()
set(PYTHON_USE_NUMPY 0)
endif()
# look for Sphinx
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__"
RESULT_VARIABLE SPHINX_PROCESS
OUTPUT_VARIABLE SPHINX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HAVE_SPHINX 0)
if(SPHINX_PROCESS EQUAL 0)
find_host_program(SPHINX_BUILD sphinx-build)
if(SPHINX_BUILD)
set(HAVE_SPHINX 1)
message(STATUS " Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}")
endif()
endif()

@ -0,0 +1,63 @@
if(UNIX AND NOT APPLE AND NOT ANDROID)
PKG_CHECK_MODULES(TBB tbb)
if(TBB_FOUND)
set(HAVE_TBB 1)
if(NOT ${TBB_INCLUDE_DIRS} STREQUAL "")
include_directories(${TBB_INCLUDE_DIRS})
endif()
link_directories(${TBB_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${TBB_LIBRARIES})
endif()
endif()
if(NOT HAVE_TBB)
set(TBB_DEFAULT_INCLUDE_DIRS "/opt/intel/tbb" "/usr/local/include" "/usr/include" "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB" "C:/Program Files (x86)/TBB" "${CMAKE_INSTALL_PREFIX}/include")
find_path(TBB_INCLUDE_DIR "tbb/tbb.h" PATHS ${TBB_DEFAULT_INCLUDE_DIRS} DOC "The path to TBB headers")
if(TBB_INCLUDE_DIR)
if(UNIX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
endif()
if(APPLE)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} libtbb.dylib)
elseif(ANDROID)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
add_definitions(-DTBB_USE_GCC_BUILTINS)
elseif (UNIX)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
elseif (WIN32)
if(CMAKE_COMPILER_IS_GNUCXX)
set(TBB_LIB_DIR "${TBB_INCLUDE_DIR}/../lib" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
else()
get_filename_component(_TBB_LIB_PATH "${TBB_INCLUDE_DIR}/../lib" ABSOLUTE)
if(CMAKE_SYSTEM_PROCESSOR MATCHES amd64*|x86_64* OR MSVC64)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/intel64")
elseif()
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/ia32")
endif()
if(MSVC80)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc8")
elseif(MSVC90)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc9")
elseif(MSVC10)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc10")
elseif(MSVC11)
set(_TBB_LIB_PATH "${_TBB_LIB_PATH}/vc11")
endif()
set(TBB_LIB_DIR "${_TBB_LIB_PATH}" CACHE PATH "Full path of TBB library directory")
link_directories("${TBB_LIB_DIR}")
endif()
endif()
set(HAVE_TBB 1)
if(NOT "${TBB_INCLUDE_DIR}" STREQUAL "")
include_directories("${TBB_INCLUDE_DIR}")
endif()
endif(TBB_INCLUDE_DIR)
endif(NOT HAVE_TBB)

@ -0,0 +1,53 @@
# ----------------------------------------------------------------------------
# Uninstall target, for "make uninstall"
# ----------------------------------------------------------------------------
CONFIGURE_FILE(
"${OpenCV_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# ----------------------------------------------------------------------------
# Source package, for "make package_source"
# ----------------------------------------------------------------------------
if(BUILD_PACKAGE)
set(TARBALL_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
if (NOT WIN32)
if(APPLE)
set(TAR_CMD gnutar)
else()
set(TAR_CMD tar)
endif()
set(TAR_TRANSFORM "\"s,^,${TARBALL_NAME}/,\"")
add_custom_target(package_source
#TODO: maybe we should not remove dll's
COMMAND ${TAR_CMD} --transform ${TAR_TRANSFORM} -cjpf ${CMAKE_CURRENT_BINARY_DIR}/${TARBALL_NAME}.tar.bz2 --exclude=".svn" --exclude="*.pyc" --exclude="*.vcproj" --exclude="*/lib/*" --exclude="*.dll" ./
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
else()
add_custom_target(package_source
COMMAND zip -9 -r ${CMAKE_CURRENT_BINARY_DIR}/${TARBALL_NAME}.zip . -x '*/.svn/*' '*.vcproj' '*.pyc'
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
endif()
#-----------------------------------
# performance tests, for "make perf"
#-----------------------------------
if(BUILD_PERF_TESTS AND PYTHON_EXECUTABLE)
if(CMAKE_VERSION VERSION_GREATER "2.8.2")
add_custom_target(perf
${PYTHON_EXECUTABLE} "${OpenCV_SOURCE_DIR}/modules/ts/misc/run.py" --configuration $<CONFIGURATION> "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS "${OpenCV_SOURCE_DIR}/modules/ts/misc/run.py"
)
else()
add_custom_target(perf
${PYTHON_EXECUTABLE} "${OpenCV_SOURCE_DIR}/modules/ts/misc/run.py" "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS "${OpenCV_SOURCE_DIR}/modules/ts/misc/run.py"
)
endif()
endif()

@ -0,0 +1,83 @@
if(ANDROID)
# --------------------------------------------------------------------------------------------
# Installation for Android ndk-build makefile: OpenCV.mk
# Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
# Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
# -------------------------------------------------------------------------------------------
# build type
if(BUILD_SHARED_LIBS)
set(OPENCV_LIBTYPE_CONFIGMAKE "SHARED")
else()
set(OPENCV_LIBTYPE_CONFIGMAKE "STATIC")
endif()
# setup lists of camera libs
foreach(abi ARMEABI ARMEABI_V7A X86)
ANDROID_GET_ABI_RAWNAME(${abi} ndkabi)
if(BUILD_ANDROID_CAMERA_WRAPPER)
if(ndkabi STREQUAL ANDROID_NDK_ABI_NAME)
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "native_camera_r${ANDROID_VERSION}")
else()
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "")
endif()
elseif(HAVE_opencv_androidcamera)
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "")
file(GLOB OPENCV_CAMERA_LIBS "${OpenCV_SOURCE_DIR}/3rdparty/lib/${ndkabi}/libnative_camera_r*.so")
if(OPENCV_CAMERA_LIBS)
list(SORT OPENCV_CAMERA_LIBS)
endif()
foreach(cam_lib ${OPENCV_CAMERA_LIBS})
get_filename_component(cam_lib "${cam_lib}" NAME)
string(REGEX REPLACE "lib(native_camera_r[0-9]+\\.[0-9]+\\.[0-9]+)\\.so" "\\1" cam_lib "${cam_lib}")
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "${OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE} ${cam_lib}")
endforeach()
endif()
endforeach()
# build the list of opencv libs and dependencies for all modules
set(OPENCV_MODULES_CONFIGMAKE "")
set(OPENCV_EXTRA_COMPONENTS_CONFIGMAKE "")
set(OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE "")
foreach(m ${OPENCV_MODULES_PUBLIC})
list(INSERT OPENCV_MODULES_CONFIGMAKE 0 ${${m}_MODULE_DEPS_${ocv_optkind}} ${m})
if(${m}_EXTRA_DEPS_${ocv_optkind})
list(INSERT OPENCV_EXTRA_COMPONENTS_CONFIGMAKE 0 ${${m}_EXTRA_DEPS_${ocv_optkind}})
endif()
endforeach()
# split 3rdparty libs and modules
foreach(mod ${OPENCV_MODULES_CONFIGMAKE})
if(NOT mod MATCHES "^opencv_.+$")
list(INSERT OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE 0 ${mod})
endif()
endforeach()
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE})
# convert CMake lists to makefile literals
foreach(lst OPENCV_MODULES_CONFIGMAKE OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE OPENCV_EXTRA_COMPONENTS_CONFIGMAKE)
ocv_list_unique(${lst})
ocv_list_reverse(${lst})
string(REPLACE ";" " " ${lst} "${${lst}}")
endforeach()
string(REPLACE "opencv_" "" OPENCV_MODULES_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
# -------------------------------------------------------------------------------------------
# Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
# -------------------------------------------------------------------------------------------
set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "\"${OpenCV_SOURCE_DIR}\"")
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)")
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" IMMEDIATE @ONLY)
# -------------------------------------------------------------------------------------------
# Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
# -------------------------------------------------------------------------------------------
set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/../../include/opencv\" \"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/../../include\"")
set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "")
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../..")
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" IMMEDIATE @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION share/OpenCV/)
endif(ANDROID)

@ -0,0 +1,130 @@
# --------------------------------------------------------------------------------------------
# Installation for CMake Module: OpenCVConfig.cmake
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use with "make install"
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
# -------------------------------------------------------------------------------------------
if(INSTALL_TO_MANGLED_PATHS)
set(OpenCV_USE_MANGLED_PATHS TRUE)
else()
set(OpenCV_USE_MANGLED_PATHS FALSE)
endif()
if(NOT OpenCV_CUDA_CC)
set(OpenCV_CUDA_CC_CONFIGMAKE "\"\"")
else()
set(OpenCV_CUDA_CC_CONFIGMAKE "${OpenCV_CUDA_CC}")
endif()
if(NOT ANDROID_NATIVE_API_LEVEL)
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGMAKE 0)
else()
set(OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGMAKE "${ANDROID_NATIVE_API_LEVEL}")
endif()
#build list of modules available for the OpenCV user
set(OpenCV_LIB_COMPONENTS "")
foreach(m ${OPENCV_MODULES_PUBLIC})
list(INSERT OpenCV_LIB_COMPONENTS 0 ${${m}_MODULE_DEPS_OPT} ${m})
endforeach()
ocv_list_unique(OpenCV_LIB_COMPONENTS)
set(OPENCV_MODULES_CONFIGMAKE ${OpenCV_LIB_COMPONENTS})
ocv_list_filterout(OpenCV_LIB_COMPONENTS "^opencv_")
if(OpenCV_LIB_COMPONENTS)
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE ${OpenCV_LIB_COMPONENTS})
endif()
macro(ocv_generate_dependencies_map_configmake suffix)
set(OPENCV_DEPENDENCIES_MAP_${suffix} "")
set(OPENCV_PROCESSED_LIBS "")
set(OPENCV_LIBS_TO_PROCESS ${OPENCV_MODULES_CONFIGMAKE})
while(OPENCV_LIBS_TO_PROCESS)
list(GET OPENCV_LIBS_TO_PROCESS 0 __ocv_lib)
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_DEPS_${suffix} ${${__ocv_lib}_MODULE_DEPS_${suffix}})\n")
set(OPENCV_DEPENDENCIES_MAP_${suffix} "${OPENCV_DEPENDENCIES_MAP_${suffix}}set(OpenCV_${__ocv_lib}_EXTRA_DEPS_${suffix} ${${__ocv_lib}_EXTRA_DEPS_${suffix}})\n")
list(APPEND OPENCV_PROCESSED_LIBS ${__ocv_lib})
list(APPEND OPENCV_LIBS_TO_PROCESS ${${__ocv_lib}_MODULE_DEPS_${suffix}})
list(REMOVE_ITEM OPENCV_LIBS_TO_PROCESS ${OPENCV_PROCESSED_LIBS})
endwhile()
unset(OPENCV_PROCESSED_LIBS)
unset(OPENCV_LIBS_TO_PROCESS)
unset(__ocv_lib)
endmacro()
ocv_generate_dependencies_map_configmake(OPT)
ocv_generate_dependencies_map_configmake(DBG)
# -------------------------------------------------------------------------------------------
# Part 1/3: ${BIN_DIR}/OpenCVConfig.cmake -> For use *without* "make install"
# -------------------------------------------------------------------------------------------
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
set(CMAKE_OPENCV2_INCLUDE_DIRS_CONFIGCMAKE "${OpenCV_SOURCE_DIR}")
set(CMAKE_LIB_DIRS_CONFIGCMAKE "${LIBRARY_OUTPUT_PATH}")
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"${CMAKE_BINARY_DIR}/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
# --------------------------------------------------------------------------------------------
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
# -------------------------------------------------------------------------------------------
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_PREFIX}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_PREFIX}\"")
set(CMAKE_OPENCV2_INCLUDE_DIRS_CONFIGCMAKE "")
if(ANDROID)
set(CMAKE_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/libs/\${ANDROID_NDK_ABI_NAME}\"")
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV/3rdparty/libs/\${ANDROID_NDK_ABI_NAME}\"")
else()
set(CMAKE_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_LIB_INSTALL_PATH}\"")
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
if(INSTALL_TO_MANGLED_PATHS)
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/share/OpenCV-${OPENCV_VERSION}/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
endif()
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
if(UNIX)
#http://www.vtk.org/Wiki/CMake/Tutorials/Packaging reference
# For a command "find_package(<name> [major[.minor]] [EXACT] [REQUIRED|QUIET])"
# cmake will look in the following dir on unix:
# <prefix>/(share|lib)/cmake/<name>*/ (U)
# <prefix>/(share|lib)/<name>*/ (U)
# <prefix>/(share|lib)/<name>*/(cmake|CMake)/ (U)
if(INSTALL_TO_MANGLED_PATHS)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake DESTINATION share/OpenCV-${OPENCV_VERSION}/)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION share/OpenCV-${OPENCV_VERSION}/)
else()
install(FILES "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" DESTINATION share/OpenCV/)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake DESTINATION share/OpenCV/)
endif()
endif()
if(ANDROID)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/android/android.toolchain.cmake" DESTINATION share/OpenCV)
endif()
# --------------------------------------------------------------------------------------------
# Part 3/3: ${BIN_DIR}/win-install/OpenCVConfig.cmake -> For use within binary installers/packages
# -------------------------------------------------------------------------------------------
if(WIN32)
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/include\" \"\${OpenCV_CONFIG_PATH}/include/opencv\"")
set(CMAKE_OPENCV2_INCLUDE_DIRS_CONFIGCMAKE "")
set(CMAKE_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/${OPENCV_LIB_INSTALL_PATH}\"")
set(CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_CONFIG_PATH}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}\"")
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
# Install the OpenCVConfig.cmake file which has the right paths pointing to the install directory
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/")
endif()

@ -0,0 +1,36 @@
# ----------------------------------------------------------------------------
# Variables for cvconfig.h.cmake
# ----------------------------------------------------------------------------
set(PACKAGE "opencv")
set(PACKAGE_BUGREPORT "opencvlibrary-devel@lists.sourceforge.net")
set(PACKAGE_NAME "opencv")
set(PACKAGE_STRING "${PACKAGE} ${OPENCV_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE}")
set(PACKAGE_VERSION "${OPENCV_VERSION}")
# platform-specific config file
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.cmake" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h")
# ----------------------------------------------------------------------------
# opencv_modules.hpp based on actual modules list
# ----------------------------------------------------------------------------
set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "")
set(OPENCV_MOD_LIST ${OPENCV_MODULES_PUBLIC})
ocv_list_sort(OPENCV_MOD_LIST)
foreach(m ${OPENCV_MOD_LIST})
string(TOUPPER "${m}" m)
set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}#define HAVE_${m} 1\n")
endforeach()
set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}\n")
set(OPENCV_MOD_LIST ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO})
ocv_list_sort(OPENCV_MOD_LIST)
foreach(m ${OPENCV_MOD_LIST})
string(TOUPPER "${m}" m)
set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE}#undef HAVE_${m}\n")
endforeach()
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv_modules.hpp.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2 COMPONENT main)

@ -0,0 +1,75 @@
# --------------------------------------------------------------------------------------------
# according to man pkg-config
# The package name specified on the pkg-config command line is defined to
# be the name of the metadata file, minus the .pc extension. If a library
# can install multiple versions simultaneously, it must give each version
# its own name (for example, GTK 1.2 might have the package name "gtk+"
# while GTK 2.0 has "gtk+-2.0").
#
# ${BIN_DIR}/unix-install/opencv.pc -> For use *with* "make install"
# -------------------------------------------------------------------------------------------
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "") #TODO: need link paths for OpenCV_EXTRA_COMPONENTS
set(includedir "\${prefix}/${OPENCV_INCLUDE_PREFIX}")
set(VERSION ${OPENCV_VERSION})
if(CMAKE_BUILD_TYPE MATCHES "Release")
set(ocv_optkind OPT)
else()
set(ocv_optkind DBG)
endif()
#build the list of opencv libs and dependencies for all modules
set(OpenCV_LIB_COMPONENTS "")
set(OpenCV_EXTRA_COMPONENTS "")
foreach(m ${OPENCV_MODULES_PUBLIC})
list(INSERT OpenCV_LIB_COMPONENTS 0 ${${m}_MODULE_DEPS_${ocv_optkind}} ${m})
if(${m}_EXTRA_DEPS_${ocv_optkind})
list(INSERT OpenCV_EXTRA_COMPONENTS 0 ${${m}_EXTRA_DEPS_${ocv_optkind}})
endif()
endforeach()
ocv_list_unique(OpenCV_LIB_COMPONENTS)
ocv_list_unique(OpenCV_EXTRA_COMPONENTS)
ocv_list_reverse(OpenCV_LIB_COMPONENTS)
ocv_list_reverse(OpenCV_EXTRA_COMPONENTS)
#build the list of components
set(OpenCV_LIB_COMPONENTS_ "")
foreach(CVLib ${OpenCV_LIB_COMPONENTS})
get_target_property(libpath ${CVLib} LOCATION_${CMAKE_BUILD_TYPE})
get_filename_component(libname "${libpath}" NAME)
if(INSTALL_TO_MANGLED_PATHS)
set(libname "${libname}.${OPENCV_VERSION}")
endif()
#need better solution....
if(libpath MATCHES "3rdparty")
set(installDir "share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}")
else()
set(installDir "${OPENCV_LIB_INSTALL_PATH}")
endif()
set(OpenCV_LIB_COMPONENTS_ "${OpenCV_LIB_COMPONENTS_} \${exec_prefix}/${installDir}/${libname}")
endforeach()
# add extra dependencies required for OpenCV
set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_})
if(OpenCV_EXTRA_COMPONENTS)
string(REPLACE ";" " " OpenCV_EXTRA_COMPONENTS "${OpenCV_EXTRA_COMPONENTS}")
set(OpenCV_LIB_COMPONENTS "${OpenCV_LIB_COMPONENTS} ${OpenCV_EXTRA_COMPONENTS}")
endif()
#generate the .pc file
if(INSTALL_TO_MANGLED_PATHS)
set(OPENCV_PC_FILE_NAME "opencv-${OPENCV_VERSION}.pc")
else()
set(OPENCV_PC_FILE_NAME opencv.pc)
endif()
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv-XXX.pc.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}" @ONLY IMMEDIATE)
if(UNIX AND NOT ANDROID)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME} DESTINATION ${OPENCV_LIB_INSTALL_PATH}/pkgconfig)
endif()

@ -1,278 +1,682 @@
set(opencv_public_modules "" CACHE INTERNAL "List of OpenCV modules included into the build")
# helper macro for modules management
macro(opencv_module_register name)
set(opencv_public_modules ${opencv_public_modules} ${name} CACHE INTERNAL "List of OpenCV modules included into the build")
endmacro()
# Setup include path for OpenCV headers for specified modules
macro(opencv_module_includes)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_BINARY_DIR}")
foreach(d ${ARGN})
if(d MATCHES "opencv_")
string(REPLACE "opencv_" "${OpenCV_SOURCE_DIR}/modules/" d_dir ${d})
if (EXISTS "${d_dir}/include")
include_directories("${d_dir}/include")
endif()
endif()
endforeach()
# Local variables (set for each module):
#
# name - short name in lower case i.e. core
# the_module - full name in lower case i.e. opencv_core
# Global variables:
#
# OPENCV_MODULE_${the_module}_LOCATION
# OPENCV_MODULE_${the_module}_DESCRIPTION
# OPENCV_MODULE_${the_module}_HEADERS
# OPENCV_MODULE_${the_module}_SOURCES
# OPENCV_MODULE_${the_module}_DEPS - final flattened set of module dependencies
# OPENCV_MODULE_${the_module}_DEPS_EXT
# OPENCV_MODULE_${the_module}_REQ_DEPS
# OPENCV_MODULE_${the_module}_OPT_DEPS
# HAVE_${the_module} - for fast check of module availability
# To control the setup of the module you could also set:
# the_description - text to be used as current module description
# OPENCV_MODULE_TYPE - STATIC|SHARED - set to force override global settings for current module
# The verbose template for OpenCV module:
#
# ocv_add_module(modname <dependencies>)
# ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
# ocv_module_include_directories(<extra include directories>)
# ocv_create_module()
# <add extra link dependencies, compiler options, etc>
# ocv_add_precompiled_headers(${the_module})
# <add extra installation rules>
# ocv_add_accuracy_tests(<extra dependencies>)
# ocv_add_perf_tests(<extra dependencies>)
#
#
# If module have no "extra" then you can define it in one line:
#
# ocv_define_module(modname <dependencies>)
# clean flags for modules enabled on previous cmake run
# this is necessary to correctly handle modules removal
foreach(mod ${OPENCV_MODULES_BUILD})
if(HAVE_${mod})
unset(HAVE_${mod} CACHE)
endif()
endforeach()
# clean modules info which needs to be recalculated
set(OPENCV_MODULES_PUBLIC "" CACHE INTERNAL "List of OpenCV modules marked for export")
set(OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules included into the build")
set(OPENCV_MODULES_DISABLED_USER "" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
set(OPENCV_MODULES_DISABLED_AUTO "" CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
# adds dependencies to OpenCV module
# Usage:
# add_dependencies(opencv_<name> [REQUIRED] [<list of dependencies>] [OPTIONAL <list of modules>])
# Notes:
# * <list of dependencies> - can include full names of modules or full pathes to shared/static libraries or cmake targets
macro(ocv_add_dependencies full_modname)
#we don't clean the dependencies here to allow this macro several times for every module
foreach(d "REQIRED" ${ARGN})
if(d STREQUAL "REQIRED")
set(__depsvar OPENCV_MODULE_${full_modname}_REQ_DEPS)
elseif(d STREQUAL "OPTIONAL")
set(__depsvar OPENCV_MODULE_${full_modname}_OPT_DEPS)
else()
list(APPEND ${__depsvar} "${d}")
endif()
endforeach()
if(OPENCV_MODULE_${full_modname}_REQ_DEPS)
list(REMOVE_DUPLICATES OPENCV_MODULE_${full_modname}_REQ_DEPS)
endif()
if(OPENCV_MODULE_${full_modname}_OPT_DEPS)
list(REMOVE_DUPLICATES OPENCV_MODULE_${full_modname}_OPT_DEPS)
endif()
set(OPENCV_MODULE_${full_modname}_REQ_DEPS ${OPENCV_MODULE_${full_modname}_REQ_DEPS} CACHE INTERNAL "Required dependencies of ${full_modname} module")
set(OPENCV_MODULE_${full_modname}_OPT_DEPS ${OPENCV_MODULE_${full_modname}_OPT_DEPS} CACHE INTERNAL "Optional dependencies of ${full_modname} module")
unset(__depsvar)
endmacro()
# opencv precompiled headers macro (can add pch to modules and tests)
# this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
macro(add_opencv_precompiled_headers the_target)
if("${the_target}" MATCHES "opencv_test_.*")
SET(pch_name "test/test_precomp")
elseif("${the_target}" MATCHES "opencv_perf_.*")
SET(pch_name "perf/perf_precomp")
# declare new OpenCV module in current folder
# Usage:
# ocv_add_module(<name> [INTERNAL|BINDINGS] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
# Example:
# ocv_add_module(yaom INTERNAL opencv_core opencv_highgui NOLINK opencv_flann OPTIONAL opencv_gpu)
macro(ocv_add_module _name)
string(TOLOWER "${_name}" name)
string(REGEX REPLACE "^opencv_" "" ${name} "${name}")
set(the_module opencv_${name})
# the first pass - collect modules info, the second pass - create targets
if(OPENCV_INITIAL_PASS)
#remember module details
if(NOT DEFINED the_description)
set(the_description "The ${name} OpenCV module")
endif()
set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module")
set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources")
#create option to enable/disable this module
option(BUILD_${the_module} "Include ${the_module} module into the OpenCV build" ON)
if(NOT BUILD_${the_module})
set(OPENCV_MODULES_DISABLED_USER ${OPENCV_MODULES_DISABLED_USER} "${the_module}" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user")
else()
SET(pch_name "src/precomp")
#register new module
if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS")
set(__ocv_argn__ ${ARGN})
list(REMOVE_AT __ocv_argn__ 0)
ocv_add_dependencies(${the_module} ${__ocv_argn__})
unset(__ocv_argn__)
else()
ocv_add_dependencies(${the_module} ${ARGN})
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} "${the_module}" CACHE INTERNAL "List of OpenCV modules marked for export")
endif()
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} "${the_module}" CACHE INTERNAL "List of OpenCV modules included into the build")
endif()
set(pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${pch_name}.hpp")
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
if(CMAKE_GENERATOR MATCHES Visual)
set(${the_target}_pch "${CMAKE_CURRENT_SOURCE_DIR}/${pch_name}.cpp")
add_native_precompiled_header(${the_target} ${pch_header})
elseif(CMAKE_GENERATOR MATCHES Xcode)
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()
#TODO: add submodules if any
#stop processing of current file
return()
else(OPENCV_INITIAL_PASS)
if(NOT BUILD_${the_module})
#extra protection from redefinition
return()
endif()
project(${the_module})
endif(OPENCV_INITIAL_PASS)
endmacro()
# this is a template for a OpenCV performance tests
# define_opencv_perf_test(<module_name> <extra_dependencies>)
macro(define_opencv_perf_test name)
set(perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf")
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}")
# opencv_highgui is required for imread/imwrite
set(perf_deps opencv_${name} ${ARGN} opencv_ts opencv_highgui ${EXTRA_OPENCV_${name}_DEPS})
include_directories("${perf_path}")
opencv_module_includes(${perf_deps})
file(GLOB perf_srcs "${perf_path}/*.cpp")
file(GLOB perf_hdrs "${perf_path}/*.h*")
source_group("Src" FILES ${perf_srcs})
source_group("Include" FILES ${perf_hdrs})
# Internal macro; disables OpenCV module
# ocv_module_turn_off(<module name>)
macro(__ocv_module_turn_off the_module)
list(APPEND OPENCV_MODULES_DISABLED_AUTO "${the_module}")
list(REMOVE_ITEM OPENCV_MODULES_BUILD "${the_module}")
list(REMOVE_ITEM OPENCV_MODULES_PUBLIC "${the_module}")
set(HAVE_${the_module} OFF CACHE INTERNAL "Module ${the_module} can not be built in current configuration")
endmacro()
set(the_target "opencv_perf_${name}")
add_executable(${the_target} ${perf_srcs} ${perf_hdrs})
macro(ocv_module_disable module)
set(__modname ${module})
if(NOT __modname MATCHES "^opencv_")
set(__modname opencv_${module})
endif()
list(APPEND OPENCV_MODULES_DISABLED_FORCE "${__modname}")
set(HAVE_${__modname} OFF CACHE INTERNAL "Module ${__modname} can not be built in current configuration")
set(OPENCV_MODULES_DISABLED_FORCE "${OPENCV_MODULES_DISABLED_FORCE}" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
unset(__modname)
return()#leave the current folder
endmacro()
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "performance tests")
endif()
macro(__ocv_flatten_module_required_dependencies the_module)
set(__flattened_deps "")
set(__resolved_deps "")
set(__req_depends ${OPENCV_MODULE_${the_module}_REQ_DEPS})
while(__req_depends)
list(GET __req_depends 0 __dep)
list(REMOVE_AT __req_depends 0)
if(__dep STREQUAL the_module)
#TODO: think how to deal with cyclic dependency
__ocv_module_turn_off(${the_module})
break()
elseif("${OPENCV_MODULES_DISABLED_USER};${OPENCV_MODULES_DISABLED_AUTO}" MATCHES "(^|;)${__dep}(;|$)")
#depends on disabled module
__ocv_module_turn_off(${the_module})
break()
elseif("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)")
if(__resolved_deps MATCHES "(^|;)${__dep}(;|$)")
#all dependencies of this module are already resolved
list(APPEND __flattened_deps "${__dep}")
else()
#put all required subdependencies before this dependency and mark it as resolved
list(APPEND __resolved_deps "${__dep}")
list(INSERT __req_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${__dep})
endif()
elseif(__dep MATCHES "^opencv_")
#depends on missing module
__ocv_module_turn_off(${the_module})
break()
else()
#skip non-modules
endif()
endwhile()
if(__flattened_deps)
list(REMOVE_DUPLICATES __flattened_deps)
set(OPENCV_MODULE_${the_module}_DEPS ${__flattened_deps})
else()
set(OPENCV_MODULE_${the_module}_DEPS "")
endif()
unset(__resolved_deps)
unset(__flattened_deps)
unset(__req_depends)
unset(__dep)
endmacro()
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${perf_deps})
macro(__ocv_flatten_module_optional_dependencies the_module)
set(__flattened_deps ${OPENCV_MODULE_${the_module}_DEPS})
set(__resolved_deps ${OPENCV_MODULE_${the_module}_DEPS})
set(__opt_depends ${OPENCV_MODULE_${the_module}_OPT_DEPS})
while(__opt_depends)
list(GET __opt_depends 0 __dep)
list(REMOVE_AT __opt_depends 0)
if(__dep STREQUAL the_module)
#TODO: think how to deal with cyclic dependency
__ocv_module_turn_off(${the_module})
break()
elseif("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)")
if(__resolved_deps MATCHES "(^|;)${__dep}(;|$)")
#all dependencies of this module are already resolved
list(APPEND __flattened_deps "${__dep}")
else()
#put all subdependencies before this dependency and mark it as resolved
list(APPEND __resolved_deps "${__dep}")
list(INSERT __opt_depends 0 ${OPENCV_MODULE_${__dep}_REQ_DEPS} ${OPENCV_MODULE_${__dep}_OPT_DEPS} ${__dep})
endif()
else()
#skip non-modules or missing modules
endif()
endwhile()
if(__flattened_deps)
list(REMOVE_DUPLICATES __flattened_deps)
set(OPENCV_MODULE_${the_module}_DEPS ${__flattened_deps})
else()
set(OPENCV_MODULE_${the_module}_DEPS "")
endif()
unset(__resolved_deps)
unset(__flattened_deps)
unset(__opt_depends)
unset(__dep)
endmacro()
add_opencv_precompiled_headers(${the_target})
macro(__ocv_flatten_module_dependencies)
foreach(m ${OPENCV_MODULES_DISABLED_USER})
set(HAVE_${m} OFF CACHE INTERNAL "Module ${m} will not be built in current configuration")
endforeach()
foreach(m ${OPENCV_MODULES_BUILD})
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will not be built in current configuration")
__ocv_flatten_module_required_dependencies(${m})
endforeach()
foreach(m ${OPENCV_MODULES_BUILD})
__ocv_flatten_module_optional_dependencies(${m})
#dependencies from other modules
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module")
#extra dependencies
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_REQ_DEPS} ${OPENCV_MODULE_${m}_OPT_DEPS})
if(OPENCV_MODULE_${m}_DEPS_EXT AND OPENCV_MODULE_${m}_DEPS)
list(REMOVE_ITEM OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS})
endif()
ocv_list_filterout(OPENCV_MODULE_${m}_DEPS_EXT "^opencv_[^ ]+$")
set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS_EXT} CACHE INTERNAL "Extra dependencies of ${m} module")
endforeach()
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export")
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} CACHE INTERNAL "List of OpenCV modules included into the build")
set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
endmacro()
if (PYTHON_EXECUTABLE)
add_dependencies(perf ${the_target})
# collect modules from specified directories
# NB: must be called only once!
macro(ocv_glob_modules)
#collect modules
set(OPENCV_INITIAL_PASS ON)
foreach(__path ${ARGN})
file(GLOB __ocvmodules RELATIVE "${__path}" "${__path}/*")
if(__ocvmodules)
list(SORT __ocvmodules)
foreach(mod ${__ocvmodules})
if(EXISTS "${__path}/${mod}/CMakeLists.txt")
add_subdirectory("${__path}/${mod}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}")
endif()
endforeach()
endif()
endforeach()
unset(__ocvmodules)
#resolve dependencies
__ocv_flatten_module_dependencies()
#create modules
set(OPENCV_INITIAL_PASS OFF)
foreach(m ${OPENCV_MODULES_BUILD})
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
endforeach()
unset(__shortname)
endmacro()
# this is a template for a OpenCV regression tests
# define_opencv_test(<module_name> <extra_dependencies>)
macro(define_opencv_test name)
set(test_path "${CMAKE_CURRENT_SOURCE_DIR}/test")
if(BUILD_TESTS AND EXISTS "${test_path}")
# opencv_highgui is required for imread/imwrite
set(test_deps opencv_${name} ${ARGN} opencv_ts opencv_highgui ${EXTRA_OPENCV_${name}_DEPS})
include_directories("${test_path}")
opencv_module_includes(${test_deps})
file(GLOB test_srcs "${test_path}/*.cpp")
file(GLOB test_hdrs "${test_path}/*.h*")
# setup include paths for the list of passed modules
macro(ocv_include_modules)
foreach(d ${ARGN})
if(d MATCHES "^opencv_" AND HAVE_${d})
if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include")
include_directories("${OPENCV_MODULE_${d}_LOCATION}/include")
endif()
elseif(EXISTS "${d}")
include_directories("${d}")
endif()
endforeach()
endmacro()
source_group("Src" FILES ${test_srcs})
source_group("Include" FILES ${test_hdrs})
# setup include path for OpenCV headers for specified module
# ocv_module_include_directories(<extra include directories/extra include modules>)
macro(ocv_module_include_directories)
include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include"
"${OPENCV_MODULE_${the_module}_LOCATION}/src"
"${CMAKE_CURRENT_BINARY_DIR}"#for precompiled headers
)
ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN})
endmacro()
set(the_target "opencv_test_${name}")
add_executable(${the_target} ${test_srcs} ${test_hdrs})
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
# sets header and source files for the current module
# NB: all files specified as headers will be installed
# Usage:
# ocv_set_module_sources([HEADERS] <list of files> [SOURCES] <list of files>)
macro(ocv_set_module_sources)
set(OPENCV_MODULE_${the_module}_HEADERS "")
set(OPENCV_MODULE_${the_module}_SOURCES "")
foreach(f "HEADERS" ${ARGN})
if(f STREQUAL "HEADERS" OR f STREQUAL "SOURCES")
set(__filesvar "OPENCV_MODULE_${the_module}_${f}")
else()
list(APPEND ${__filesvar} "${f}")
endif()
endforeach()
# the hacky way to embeed any files into the OpenCV without modification of its build system
if(COMMAND ocv_get_module_external_sources)
ocv_get_module_external_sources()
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "tests")
endif()
set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
endmacro()
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${test_deps})
# 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)
file(GLOB lib_srcs "src/*.cpp")
file(GLOB 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")
enable_testing()
get_target_property(LOC ${the_target} LOCATION)
add_test(${the_target} "${LOC}")
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
source_group("Include" FILES ${lib_hdrs})
source_group("Include\\detail" FILES ${lib_hdrs_detail})
#if(WIN32)
# install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
#endif()
add_opencv_precompiled_headers(${the_target})
endif()
ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail} SOURCES ${lib_srcs} ${lib_int_hdrs})
endmacro()
# Set standard properties, install rules and precompiled headers for OpenCV module
macro(opencv_module_setup name)
set(the_target "opencv_${name}")
# For dynamic link numbering convenions
if(NOT ANDROID)
# Android SDK build scripts can include only .so files into final .apk
# As result we should not set version properties for Android
set_target_properties(${the_target} PROPERTIES
VERSION ${OPENCV_VERSION}
SOVERSION ${OPENCV_SOVERSION}
)
# creates OpenCV module in current folder
# creates new target, configures standard dependencies, compilers flags, install rules
# Usage:
# ocv_create_module(<extra link dependencies>)
macro(ocv_create_module)
add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES})
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_module} PROPERTIES FOLDER "modules")
endif()
set_target_properties(${the_module} PROPERTIES
OUTPUT_NAME "${the_module}${OPENCV_DLLVERSION}"
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
)
# For dynamic link numbering convenions
if(NOT ANDROID)
# Android SDK build scripts can include only .so files into final .apk
# As result we should not set version properties for Android
set_target_properties(${the_module} PROPERTIES
VERSION ${OPENCV_VERSION}
SOVERSION ${OPENCV_SOVERSION}
)
endif()
if(BUILD_SHARED_LIBS)
if(MSVC)
set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
else()
add_definitions(-DCVAPI_EXPORTS)
endif()
endif()
set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}" )
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "modules")
if(MSVC)
if(CMAKE_CROSSCOMPILING)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
endif()
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
endif()
if (BUILD_SHARED_LIBS)
if(MSVC)
set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
else()
add_definitions(-DCVAPI_EXPORTS)
endif()
endif()
install(TARGETS ${the_module}
RUNTIME DESTINATION bin COMPONENT main
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
)
)
if(MSVC)
if(CMAKE_CROSSCOMPILING)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
# only "public" headers need to be installed
if(OPENCV_MODULE_${the_module}_HEADERS AND OPENCV_MODULES_PUBLIC MATCHES "(^|;)${the_module}(;|$)")
install(FILES ${OPENCV_MODULE_${the_module}_HEADERS}
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name} COMPONENT main)
endif()
endmacro()
# opencv precompiled headers macro (can add pch to modules and tests)
# this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work
# Usage:
# ocv_add_precompiled_headers(${the_module})
macro(ocv_add_precompiled_headers the_target)
if("${the_target}" MATCHES "^opencv_test_.*$")
SET(pch_path "test/test_")
elseif("${the_target}" MATCHES "^opencv_perf_.*$")
SET(pch_path "perf/perf_")
else()
SET(pch_path "src/")
endif()
set(pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.hpp")
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
if(CMAKE_GENERATOR MATCHES Visual)
set(${the_target}_pch "${CMAKE_CURRENT_SOURCE_DIR}/${pch_path}precomp.cpp")
add_native_precompiled_header(${the_target} ${pch_header})
elseif(CMAKE_GENERATOR MATCHES Xcode)
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()
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc /DEBUG")
endif()
unset(pch_header)
unset(pch_path)
unset(${the_target}_pch)
endmacro()
install(TARGETS ${the_target}
RUNTIME DESTINATION bin COMPONENT main
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
# short command for adding simple OpenCV module
# see ocv_add_module for argument details
# 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})
ocv_glob_module_sources()
ocv_module_include_directories()
ocv_create_module()
ocv_add_precompiled_headers(${the_module})
ocv_add_accuracy_tests()
ocv_add_perf_tests()
endmacro()
if(lib_hdrs)
install(FILES ${lib_hdrs}
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
COMPONENT main)
# ensures that all passed modules are available
# sets OCV_DEPENDENCIES_FOUND variable to TRUE/FALSE
macro(ocv_check_dependencies)
set(OCV_DEPENDENCIES_FOUND TRUE)
foreach(d ${ARGN})
if(d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_${d})
set(OCV_DEPENDENCIES_FOUND FALSE)
break()
endif()
add_opencv_precompiled_headers(${the_target})
endforeach()
endmacro()
# this is a template for a OpenCV module declaration
# define_opencv_moduleEx(<module_name> [public|internal] <dependencies>)
macro(define_opencv_moduleEx _name _visibility)
string(TOLOWER "${_name}" name)
string(TOUPPER "${_name}" mname)
string(TOLOWER "${_visibility}" visibility)
option(OCVMODULE_${mname} "Include ${name} module into the OpenCV build" ON)
if(OCVMODULE_${mname})
set(the_target "opencv_${name}")
project(${the_target})
opencv_module_includes(${ARGN})
#auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands
macro(__ocv_parse_test_sources tests_type)
set(OPENCV_${tests_type}_${the_module}_SOURCES "")
set(OPENCV_${tests_type}_${the_module}_DEPS "")
set(__file_group_name "")
set(__file_group_sources "")
foreach(arg "DEPENDS_ON" ${ARGN} "FILES")
if(arg STREQUAL "FILES")
set(__currentvar "__file_group_sources")
if(__file_group_name AND __file_group_sources)
source_group("${__file_group_name}" FILES ${__file_group_sources})
list(APPEND OPENCV_${tests_type}_${the_module}_SOURCES ${__file_group_sources})
endif()
set(__file_group_name "")
set(__file_group_sources "")
elseif(arg STREQUAL "DEPENDS_ON")
set(__currentvar "OPENCV_TEST_${the_module}_DEPS")
elseif("${__currentvar}" STREQUAL "__file_group_sources" AND NOT __file_group_name)
set(__file_group_name "${arg}")
else()
list(APPEND ${__currentvar} "${arg}")
endif()
endforeach()
unset(__file_group_name)
unset(__file_group_sources)
unset(__currentvar)
endmacro()
file(GLOB lib_srcs "src/*.cpp")
file(GLOB lib_int_hdrs "src/*.h*")
file(GLOB lib_hdrs "include/opencv2/${name}/*.h*")
file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.h*")
# this is a command for adding OpenCV performance tests to the module
# ocv_add_perf_tests(<extra_dependencies>)
macro(ocv_add_perf_tests)
set(perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf")
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}")
__ocv_parse_test_sources(PERF ${ARGN})
if(COMMAND get_module_external_sources)
get_module_external_sources(${name})
endif()
# opencv_highgui is required for imread/imwrite
set(perf_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_PERF_${the_module}_DEPS})
ocv_check_dependencies(${perf_deps})
source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
source_group("Include" FILES ${lib_hdrs})
source_group("Include\\detail" FILES ${lib_hdrs_detail})
if(OCV_DEPENDENCIES_FOUND)
set(the_target "opencv_perf_${name}")
#project(${the_target})
ocv_module_include_directories(${perf_deps} "${perf_path}")
list(APPEND lib_hdrs ${lib_hdrs_detail})
if(NOT OPENCV_PERF_${the_module}_SOURCES)
file(GLOB perf_srcs "${perf_path}/*.cpp")
file(GLOB perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h")
source_group("Src" FILES ${perf_srcs})
source_group("Include" FILES ${perf_hdrs})
set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs})
endif()
if(HAVE_CUDA AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
file(GLOB lib_cuda "src/cuda/*.cu")
source_group("Cuda" FILES "${lib_cuda}")
include_directories(${CUDA_INCLUDE_DIRS})
include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src")
include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -gencode arch=compute_10,code=sm_10
-gencode arch=compute_11,code=sm_11
-gencode arch=compute_12,code=sm_12
-gencode arch=compute_13,code=sm_13
-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21)
if(UNIX OR APPLE)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fPIC)
endif()
if(APPLE)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fno-finite-math-only)
endif()
add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${perf_deps})
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-keep")
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
# we remove -ggdb3 flag as it leads to preprocessor errors when compiling CUDA files (CUDA 4.1)
set(tmp ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "-ggdb3" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
CUDA_COMPILE(cuda_objs ${lib_cuda})
set(CMAKE_CXX_DEBUG_FLAGS ${tmp})
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "tests performance")
endif()
ocv_add_precompiled_headers(${the_target})
if (PYTHON_EXECUTABLE)
add_dependencies(perf ${the_target})
endif()
else(OCV_DEPENDENCIES_FOUND)
#TODO: warn about unsatisfied dependencies
endif(OCV_DEPENDENCIES_FOUND)
endif()
endmacro()
else()
set(lib_cuda "")
set(cuda_objs "")
endif()
# this is a command for adding OpenCV accuracy/regression tests to the module
# ocv_add_accuracy_tests([FILES <source group name> <list of sources>] [DEPENDS_ON] <list of extra dependencies>)
macro(ocv_add_accuracy_tests)
set(test_path "${CMAKE_CURRENT_SOURCE_DIR}/test")
ocv_check_dependencies(${test_deps})
if(BUILD_TESTS AND EXISTS "${test_path}")
__ocv_parse_test_sources(TEST ${ARGN})
# opencv_highgui is required for imread/imwrite
set(test_deps ${the_module} opencv_ts opencv_highgui ${OPENCV_TEST_${the_module}_DEPS})
ocv_check_dependencies(${test_deps})
if(OCV_DEPENDENCIES_FOUND)
set(the_target "opencv_test_${name}")
#project(${the_target})
ocv_module_include_directories(${test_deps} "${test_path}")
add_library(${the_target} ${OPENCV_${mname}_MODULE_TYPE} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${cuda_objs})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
if(NOT OPENCV_TEST_${the_module}_SOURCES)
file(GLOB test_srcs "${test_path}/*.cpp")
file(GLOB test_hdrs "${test_path}/*.hpp" "${test_path}/*.h")
source_group("Src" FILES ${test_srcs})
source_group("Include" FILES ${test_hdrs})
set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
endif()
add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${test_deps})
if(HAVE_CUDA AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
target_link_libraries(${the_target} ${CUDA_LIBRARIES})
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
endif()
enable_testing()
get_target_property(LOC ${the_target} LOCATION)
add_test(${the_target} "${LOC}")
ocv_add_precompiled_headers(${the_target})
else(OCV_DEPENDENCIES_FOUND)
#TODO: warn about unsatisfied dependencies
endif(OCV_DEPENDENCIES_FOUND)
endif()
endmacro()
unset(CUDA_npp_LIBRARY CACHE)
find_cuda_helper_libs(npp)
target_link_libraries(${the_target} ${CUDA_npp_LIBRARY})
endif()
# internal macro; finds all link dependencies of module
# should be used at the end of CMake processing
macro(__ocv_track_module_link_dependencies the_module optkind)
set(${the_module}_MODULE_DEPS_${optkind} "")
set(${the_module}_EXTRA_DEPS_${optkind} "")
get_target_property(__module_type ${the_module} TYPE)
if(__module_type STREQUAL "STATIC_LIBRARY")
#in case of static library we have to inherit its dependencies (in right order!!!)
if(NOT DEFINED ${the_module}_LIB_DEPENDS_${optkind})
ocv_split_libs_list(${the_module}_LIB_DEPENDS ${the_module}_LIB_DEPENDS_DBG ${the_module}_LIB_DEPENDS_OPT)
endif()
if(visibility STREQUAL "public")
opencv_module_register(${the_target})
set(__resolved_deps "")
set(__mod_depends ${${the_module}_LIB_DEPENDS_${optkind}})
set(__has_cycle FALSE)
while(__mod_depends)
list(GET __mod_depends 0 __dep)
list(REMOVE_AT __mod_depends 0)
if(__dep STREQUAL the_module)
set(__has_cycle TRUE)
else()#if("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)")
ocv_regex_escape(__rdep "${__dep}")
if(__resolved_deps MATCHES "(^|;)${__rdep}(;|$)")
#all dependencies of this module are already resolved
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${__dep}")
else()
get_target_property(__module_type ${__dep} TYPE)
if(__module_type STREQUAL "STATIC_LIBRARY")
if(NOT DEFINED ${__dep}_LIB_DEPENDS_${optkind})
ocv_split_libs_list(${__dep}_LIB_DEPENDS ${__dep}_LIB_DEPENDS_DBG ${__dep}_LIB_DEPENDS_OPT)
endif()
list(INSERT __mod_depends 0 ${${__dep}_LIB_DEPENDS_${optkind}} ${__dep})
list(APPEND __resolved_deps "${__dep}")
elseif(NOT __module_type)
list(APPEND ${the_module}_EXTRA_DEPS_${optkind} "${__dep}")
endif()
endif()
opencv_module_setup(${name})
define_opencv_test(${name})
define_opencv_perf_test(${name})
#else()
# get_target_property(__dep_location "${__dep}" LOCATION)
endif()
endwhile()
ocv_list_unique(${the_module}_MODULE_DEPS_${optkind})
#ocv_list_reverse(${the_module}_MODULE_DEPS_${optkind})
ocv_list_unique(${the_module}_EXTRA_DEPS_${optkind})
#ocv_list_reverse(${the_module}_EXTRA_DEPS_${optkind})
if(__has_cycle)
#not sure if it can work
list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}")
endif()
endmacro()
# this is a shorthand for a public OpenCV module declaration
# define_opencv_module(<module_name> <dependencies>)
macro(define_opencv_module name)
define_opencv_moduleEx(${name} PUBLIC ${ARGN})
unset(__dep_location)
unset(__mod_depends)
unset(__resolved_deps)
unset(__has_cycle)
unset(__rdep)
endif()#STATIC_LIBRARY
unset(__module_type)
#message("${the_module}_MODULE_DEPS_${optkind}")
#message(" ${${the_module}_MODULE_DEPS_${optkind}}")
#message(" ${OPENCV_MODULE_${the_module}_DEPS}")
#message("")
#message("${the_module}_EXTRA_DEPS_${optkind}")
#message(" ${${the_module}_EXTRA_DEPS_${optkind}}")
#message("")
endmacro()
# creates lists of build dependencies needed for external projects
macro(ocv_track_build_dependencies)
foreach(m ${OPENCV_MODULES_BUILD})
__ocv_track_module_link_dependencies("${m}" OPT)
__ocv_track_module_link_dependencies("${m}" DBG)
endforeach()
endmacro()

@ -1,14 +1,14 @@
# Search packages for host system instead of packages for target system
# in case of cross compilation thess macro should be defined by toolchain file
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
@ -17,17 +17,17 @@ endif()
# Usage:
# option(<option_variable> "help string describing option" <initial value> [IF <condition>])
macro(OCV_OPTION variable description value)
SET(__condition ${ARGN})
if("${__condition}" STREQUAL "")
SET(__condition 1)
endif()
list(REMOVE_ITEM __condition "IF" "if")
if(${__condition})
OPTION(${variable} "${description}" ${value})
else()
UNSET(${variable} CACHE)
endif()
UNSET(__condition)
SET(__condition ${ARGN})
if("${__condition}" STREQUAL "")
SET(__condition 1)
endif()
list(REMOVE_ITEM __condition "IF" "if")
if(${__condition})
OPTION(${variable} "${description}" ${value})
else()
UNSET(${variable} CACHE)
endif()
UNSET(__condition)
endmacro()
@ -115,3 +115,62 @@ macro(status text)
message(STATUS "${text}")
endif()
endmacro()
# splits cmake libraries list of format "general;item1;debug;item2;release;item3" to two lists
macro(ocv_split_libs_list lst lstdbg lstopt)
set(${lstdbg} "")
set(${lstopt} "")
set(perv_keyword "")
foreach(word ${${lst}})
if(word STREQUAL "debug" OR word STREQUAL "optimized")
set(perv_keyword ${word})
elseif(word STREQUAL "general")
set(perv_keyword "")
elseif(perv_keyword STREQUAL "debug")
list(APPEND ${lstdbg} "${word}")
set(perv_keyword "")
elseif(perv_keyword STREQUAL "optimized")
list(APPEND ${lstopt} "${word}")
set(perv_keyword "")
else()
list(APPEND ${lstdbg} "${word}")
list(APPEND ${lstopt} "${word}")
set(perv_keyword "")
endif()
endforeach()
endmacro()
# remove all matching elements from the list
macro(ocv_list_filterout lst regex)
foreach(item ${${lst}})
if(item MATCHES "${regex}")
list(REMOVE_ITEM ${lst} "${item}")
endif()
endforeach()
endmacro()
# stable & safe duplicates removal macro
macro(ocv_list_unique __lst)
if(${__lst})
list(REMOVE_DUPLICATES ${__lst})
endif()
endmacro()
# safe list reversal macro
macro(ocv_list_reverse __lst)
if(${__lst})
list(REVERSE ${__lst})
endif()
endmacro()
# safe list sorting macro
macro(ocv_list_sort __lst)
if(${__lst})
list(SORT ${__lst})
endif()
endmacro()
# simple regex escaping routine (does not cover all cases!!!)
macro(ocv_regex_escape var regex)
string(REGEX REPLACE "([+.*^$])" "\\\\1" ${var} "${regex}")
endmacro()

@ -0,0 +1,28 @@
SET(OPENCV_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/modules/core/include/opencv2/core/version.hpp")
FILE(STRINGS "${OPENCV_VERSION_FILE}" OPENCV_VERSION_PARTS REGEX "#define CV_.+OR_VERSION[ ]+[0-9]+" )
string(REGEX REPLACE ".+CV_MAJOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJOR "${OPENCV_VERSION_PARTS}")
string(REGEX REPLACE ".+CV_MINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}")
string(REGEX REPLACE ".+CV_SUBMINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}")
set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}")
# create a dependency on version file
# we never use output of the following command but cmake will rerun automatically if the version file changes
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
if(WIN32)
# Postfix of DLLs:
set(OPENCV_DLLVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
set(OPENCV_DEBUG_POSTFIX d)
else()
# Postfix of so's:
set(OPENCV_DLLVERSION "")
set(OPENCV_DEBUG_POSTFIX)
endif()
#name mangling
set(OPENCV_INCLUDE_PREFIX include)
if(INSTALL_TO_MANGLED_PATHS)
set(OPENCV_INCLUDE_PREFIX include/opencv-${OPENCV_VERSION})
endif()

@ -1,33 +1,37 @@
# In order to compile your application under cygwin
# you need to define NDK_USE_CYGPATH=1 before calling ndk-build
# you might need to define NDK_USE_CYGPATH=1 before calling the ndk-build
USER_LOCAL_PATH:=$(LOCAL_PATH)
LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
OPENCV_THIS_DIR:=$(patsubst $(LOCAL_PATH)\\%,%,$(patsubst $(LOCAL_PATH)/%,%,$(call my-dir)))
OPENCV_LIBS_DIR:=@CMAKE_LIBS_DIR_CONFIGCMAKE@
OPENCV_BASEDIR:=@CMAKE_BASE_INCLUDE_DIR_CONFIGCMAKE@
OPENCV_LOCAL_C_INCLUDES:=@CMAKE_INCLUDE_DIRS_CONFIGCMAKE@
OPENCV_LIBS_DIR:=@OPENCV_LIBS_DIR_CONFIGCMAKE@
OPENCV_BASEDIR:=@OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE@
OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@
OPENCV_MODULES := contrib legacy stitching objdetect calib3d features2d video highgui imgproc ml flann core
OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
ifeq (${OPENCV_CAMERA_MODULES},off)
OPENCV_CAMERA_MODULES:=
else
OPENCV_CAMERA_MODULES:=@CMAKE_CAMERA_LIBS_CONFIGCMAKE@
ifeq ($(TARGET_ARCH_ABI),armeabi)
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_CONFIGCMAKE@
endif
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_V7A_CONFIGCMAKE@
endif
ifeq ($(TARGET_ARCH_ABI),x86)
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_X86_CONFIGCMAKE@
endif
endif
OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
ifeq ($(OPENCV_LIB_TYPE),SHARED)
OPENCV_LIB_SUFFIX:=so
OPENCV_EXTRA_COMPONENTS:=
else
OPENCV_LIB_SUFFIX:=a
ifeq (@WITH_ANDROID_CAMERA@,ON)
OPENCV_MODULES+= androidcamera
endif
OPENCV_EXTRA_COMPONENTS:=@JPEG_LIBRARIES@ @PNG_LIBRARIES@ @TIFF_LIBRARIES@ @JASPER_LIBRARIES@ @ZLIB_LIBRARY@
endif
define add_opencv_module
@ -37,7 +41,7 @@ define add_opencv_module
include $(PREBUILT_@OPENCV_LIBTYPE_CONFIGMAKE@_LIBRARY)
endef
define add_opencv_extra_component
define add_opencv_3rdparty_component
include $(CLEAR_VARS)
LOCAL_MODULE:=$1
LOCAL_SRC_FILES:=$(OPENCV_THIS_DIR)/3rdparty/libs/$(TARGET_ARCH_ABI)/lib$1.a
@ -52,7 +56,7 @@ define add_opencv_camera_module
endef
$(foreach module,$(OPENCV_MODULES),$(eval $(call add_opencv_module,$(module))))
$(foreach module,$(OPENCV_EXTRA_COMPONENTS),$(eval $(call add_opencv_extra_component,$(module))))
$(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module))))
$(foreach module,$(OPENCV_CAMERA_MODULES),$(eval $(call add_opencv_camera_module,$(module))))
ifneq ($(OPENCV_BASEDIR),)
@ -70,5 +74,7 @@ include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
LOCAL_STATIC_LIBRARIES += $(OPENCV_LOCAL_LIBRARIES)
LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib))
#restore the LOCAL_PATH
LOCAL_PATH:=$(USER_LOCAL_PATH)

@ -6,43 +6,50 @@
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# FIND_PACKAGE(OpenCV REQUIRED )
# FIND_PACKAGE(OpenCV REQUIRED)
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${OpenCV_LIBS})
#
# Or you can search for specific OpenCV modules:
#
# FIND_PACKAGE(OpenCV REQUIRED core highgui)
#
# If the module found then OPENCV_<MODULE>_FOUND is set.
#
# This file will define the following variables:
# - OpenCV_LIBS : The list of libraries to links against.
# - OpenCV_LIB_DIR : The directory where lib files are. Calling LINK_DIRECTORIES
# with this path is NOT needed.
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
# - OpenCV_VERSION : The version of this OpenCV build. Example: "@OPENCV_VERSION@"
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_MAJOR@"
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_MINOR@"
# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_PATCH@"
# -
# - OpenCV_LIBS : The list of libraries to links against.
# - OpenCV_LIB_DIR : The directory where lib files are. Calling LINK_DIRECTORIES
# with this path is NOT needed.
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API
# - OpenCV_VERSION : The version of this OpenCV build. Example: "@OPENCV_VERSION@"
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_MAJOR@"
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_MINOR@"
# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_PATCH@"
#
# Advanced variables:
# - OpenCV_SHARED
# - OpenCV_CONFIG_PATH
# - OpenCV_INSTALL_PATH
# - OpenCV_LIB_COMPONENTS
# - OpenCV_EXTRA_COMPONENTS
# - OpenCV_USE_MANGLED_PATHS
# - OpenCV_HAVE_ANDROID_CAMERA
# - OpenCV_SOURCE_PATH
#
# =================================================================================================
# ======================================================
# Version Compute Capability from which library OpenCV
# has been compiled is remembered
# ======================================================
SET(OpenCV_COMPUTE_CAPABILITIES @OpenCV_CUDA_CC@)
# Version Compute Capability from which OpenCV has been compiled is remembered
set(OpenCV_COMPUTE_CAPABILITIES @OpenCV_CUDA_CC_CONFIGMAKE@)
# Android API level from which OpenCV has been compiled is remembered
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGMAKE@)
# Some additional settings are required if OpenCV is built as static libs
set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
# Enables mangled install paths, that help with side by side installs
set(OpenCV_USE_MANGLED_PATHS @OPENCV_MANGLED_INSTALL_PATHS@)
set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS@)
# Extract the directory where *this* file has been installed (determined at cmake run-time)
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
@ -50,86 +57,172 @@ get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings
get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../.." REALPATH)
# Presence of Android native camera support
set (OpenCV_HAVE_ANDROID_CAMERA @WITH_ANDROID_CAMERA@)
# Presence of Android native camera wrappers
set(OpenCV_HAVE_ANDROID_CAMERA @HAVE_opencv_androidcamera@)
# ======================================================
# Include directories to add to the user project:
# ======================================================
# Provide the include directories to the caller
SET(OpenCV_INCLUDE_DIRS @CMAKE_INCLUDE_DIRS_CONFIGCMAKE@)
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
set(OpenCV_INCLUDE_DIRS @CMAKE_INCLUDE_DIRS_CONFIGCMAKE@)
include_directories(${OpenCV_INCLUDE_DIRS})
# ======================================================
# Link directories to add to the user project:
# ======================================================
# Provide the libs directory anyway, it may be needed in some cases.
# Provide the libs directories to the caller
SET(OpenCV_LIB_DIR @CMAKE_LIB_DIRS_CONFIGCMAKE@)
LINK_DIRECTORIES(${OpenCV_LIB_DIR})
link_directories(${OpenCV_LIB_DIR})
# ======================================================
# Version variables:
# ======================================================
SET(OpenCV_VERSION @OPENCV_VERSION@)
SET(OpenCV_VERSION_MAJOR @OPENCV_VERSION_MAJOR@)
SET(OpenCV_VERSION_MINOR @OPENCV_VERSION_MINOR@)
SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
# ====================================================================
# Link libraries: e.g. libopencv_core.so, opencv_imgproc220d.lib, etc...
# ====================================================================
# OpenCV internal dependencies:
# opencv_androidcamera -> {}
# opencv_core -> {}
# opencv_flann -> {opencv_core}
# opencv_imgproc -> {opencv_core}
# opencv_ml -> {opencv_core}
# opencv_highgui -> {opencv_core, opencv_imgproc, opencv_androidcamera}
# opencv_video -> {opencv_core, opencv_imgproc}
# opencv_features2d -> {opencv_core, opencv_imgproc, opencv_flann, opencv_highgui}
# opencv_calib3d -> {opencv_core, opencv_imgproc, opencv_flann, opencv_features2d}
# opencv_objdetect -> {opencv_core, opencv_imgproc, opencv_flann, opencv_highgui, opencv_features2d, opencv_calib3d}
# opencv_gpu -> {opencv_core, opencv_imgproc, opencv_flann, opencv_features2d, opencv_calib3d, opencv_objdetect}
# opencv_stitching -> {opencv_core, opencv_imgproc, opencv_flann, opencv_features2d, opencv_calib3d, opencv_objdetect, opencv_gpu}
# opencv_legacy -> {opencv_core, opencv_imgproc, opencv_flann, opencv_highgui, opencv_features2d, opencv_calib3d, opencv_video}
# opencv_contrib -> {opencv_core, opencv_imgproc, opencv_flann, opencv_highgui, opencv_features2d, opencv_calib3d, opencv_objdetect, opencv_video, opencv_ml}
SET(OpenCV_LIB_COMPONENTS opencv_contrib opencv_legacy opencv_stitching opencv_gpu opencv_objdetect opencv_calib3d opencv_features2d opencv_video opencv_highgui opencv_ml opencv_imgproc opencv_flann opencv_core opencv_androidcamera)
# remove modules unavailable on current platform:
if(ANDROID)
LIST(REMOVE_ITEM OpenCV_LIB_COMPONENTS opencv_gpu)
SET(OpenCV_LIB_ANDROID @OpenCV_LIB_ANDROID@)
IF(OpenCV_LIB_ANDROID)
SET(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS} ${OpenCV_LIB_ANDROID})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-shlib-undefined")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-shlib-undefined")
ENDIF()
SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGMAKE@)
@OPENCV_DEPENDENCIES_MAP_OPT@
@OPENCV_DEPENDENCIES_MAP_DBG@
# ==============================================================
# Check OpenCV availability
# ==============================================================
if(ANDROID AND OpenCV_ANDROID_NATIVE_API_LEVEL LESS ANDROID_NATIVE_API_LEVEL)
message(FATAL_ERROR "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
#always FATAL_ERROR because we can't say to the caller that OpenCV is not found
#http://www.mail-archive.com/cmake@cmake.org/msg37831.html
if(OpenCV_FIND_REQUIRED)
message(FATAL_ERROR "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
elseif(NOT OpenCV_FIND_QUIETLY)
message(WARNING "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
endif()
set(OpenCV_FOUND "OpenCV_FOUND-NOTFOUND")
return()#Android toolchain requires CMake > 2.6
endif()
if(NOT ANDROID OR OpenCV_SHARED OR NOT OpenCV_HAVE_ANDROID_CAMERA)
LIST(REMOVE_ITEM OpenCV_LIB_COMPONENTS opencv_androidcamera)
# ==============================================================
# Form list of modules (components) to find
# ==============================================================
if(NOT OpenCV_FIND_COMPONENTS)
set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS})
endif()
#expand short module names
set(OpenCV_FIND_COMPONENTS_ "")
foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
if(NOT __cvcomponent MATCHES "^opencv_")
set(__cvcomponent opencv_${__cvcomponent})
endif()
list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx)
if(__cvcomponentIdx LESS 0)
if(OpenCV_FIND_REQUIRED)
message(FATAL_ERROR "${__cvcomponent} is required but was not found")
elseif(NOT OpenCV_FIND_QUIETLY)
message(WARNING "${__cvcomponent} is required but was not found")
endif()
string(TOUPPER "${__cvcomponent}" __cvcomponent)
set(${__cvcomponent}_FOUND "${__cvcomponent}_FOUND-NOTFOUND")
else()
list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent})
endif()
endforeach()
set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
# ==============================================================
# Resolve dependencies
# ==============================================================
if(OpenCV_USE_MANGLED_PATHS)
#be explicit about the library names.
set(OpenCV_LIB_COMPONENTS_ )
foreach( CVLib ${OpenCV_LIB_COMPONENTS})
list(APPEND OpenCV_LIB_COMPONENTS_ ${OpenCV_LIB_DIR}/lib${CVLib}.so.@OPENCV_VERSION@ )
endforeach()
set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_})
set(OpenCV_LIB_SUFFIX_DBG ".so.${OpenCV_VERSION}")
set(OpenCV_LIB_SUFFIX_OPT ".so.${OpenCV_VERSION}")
else()
set(OpenCV_LIB_SUFFIX_DBG "@OPENCV_DLLVERSION@@OPENCV_DEBUG_POSTFIX@")
set(OpenCV_LIB_SUFFIX_OPT "@OPENCV_DLLVERSION@")
endif()
set(OpenCV_3RDPARTY_LIB_SUFFIX_DBG "@OPENCV_DEBUG_POSTFIX@")
set(OpenCV_3RDPARTY_LIB_SUFFIX_OPT "")
SET(OpenCV_LIBS "")
if(WIN32)
foreach(__CVLIB ${OpenCV_LIB_COMPONENTS})
# CMake>=2.6 supports the notation "debug XXd optimized XX"
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
# Modern CMake:
SET(OpenCV_LIBS ${OpenCV_LIBS} debug ${__CVLIB}@OPENCV_DLLVERSION@@OPENCV_DEBUG_POSTFIX@ optimized ${__CVLIB}@OPENCV_DLLVERSION@)
# choose required dependencies
set(OpenCV_NEED_3RDPARTY_LINK_DEPS FALSE)
set(OpenCV_REQUIRED_MODULES ${OpenCV_FIND_COMPONENTS})
foreach(__opttype OPT DBG)
SET(OpenCV_LIBS_${__opttype} "")
SET(OpenCV_EXTRA_LIBS_${__opttype} "")
foreach(__cvlib ${OpenCV_FIND_COMPONENTS})
foreach(__cvdep ${OpenCV_${__cvlib}_DEPS_${__opttype}})
if(__cvdep MATCHES "^opencv_")
list(APPEND OpenCV_LIBS_${__opttype} ${__cvdep}${OpenCV_LIB_SUFFIX_${__opttype}})
list(APPEND OpenCV_REQUIRED_MODULES ${__cvdep})
#indicate that this module is also found
string(TOUPPER "${__cvdep}" __cvdep)
set(${__cvdep}_FOUND 1)
else()
# Old CMake:
SET(OpenCV_LIBS ${OpenCV_LIBS} ${__CVLIB}@OPENCV_DLLVERSION@)
list(APPEND OpenCV_LIBS_${__opttype} ${__cvdep}${OpenCV_3RDPARTY_LIB_SUFFIX_${__opttype}})
set(OpenCV_NEED_3RDPARTY_LINK_DEPS TRUE)
endif()
endforeach()
list(APPEND OpenCV_LIBS_${__opttype} ${__cvlib}${OpenCV_LIB_SUFFIX_${__opttype}})
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${OpenCV_${__cvlib}_EXTRA_DEPS_${__opttype}})
#indicate that module is found
string(TOUPPER "${__cvlib}" __cvlib)
set(${__cvlib}_FOUND 1)
endforeach()
else()
foreach(__CVLIB ${OpenCV_LIB_COMPONENTS})
SET(OpenCV_LIBS ${OpenCV_LIBS} ${__CVLIB})
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
if(OpenCV_LIBS_${__opttype})
list(REMOVE_DUPLICATES OpenCV_LIBS_${__opttype})
endif()
if(OpenCV_EXTRA_LIBS_${__opttype})
list(REMOVE_DUPLICATES OpenCV_EXTRA_LIBS_${__opttype})
endif()
if(OpenCV_REQUIRED_MODULES)
list(REMOVE_DUPLICATES OpenCV_REQUIRED_MODULES)
endif()
else()
#TODO: duplicates are annoying but they should not be the problem
endif()
endforeach()
if(OpenCV_NEED_3RDPARTY_LINK_DEPS)
list(APPEND OpenCV_LIB_DIR @CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE@)
link_directories(@CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE@)
endif()
if(OpenCV_LIBS_DBG)
list(REVERSE OpenCV_LIBS_DBG)
endif()
if(OpenCV_LIBS_OPT)
list(REVERSE OpenCV_LIBS_OPT)
endif()
# CMake>=2.6 supports the notation "debug XXd optimized XX"
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
# Modern CMake:
SET(OpenCV_LIBS "")
foreach(__cvlib ${OpenCV_LIBS_DBG} ${OpenCV_EXTRA_LIBS_DBG})
list(APPEND OpenCV_LIBS debug "${__cvlib}")
endforeach()
foreach(__cvlib ${OpenCV_LIBS_OPT} ${OpenCV_EXTRA_LIBS_OPT})
list(APPEND OpenCV_LIBS optimized "${__cvlib}")
endforeach()
else()
# Old CMake:
if(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(OpenCV_LIBS ${OpenCV_LIBS_DBG} ${OpenCV_EXTRA_LIBS_DBG})
else()
SET(OpenCV_LIBS ${OpenCV_LIBS_OPT} ${OpenCV_EXTRA_LIBS_OPT})
endif()
endif()
# ==============================================================
@ -137,62 +230,33 @@ endif()
# ==============================================================
SET(OpenCV_SOURCE_PATH "@CMAKE_OPENCV2_INCLUDE_DIRS_CONFIGCMAKE@")
if(NOT "${OpenCV_SOURCE_PATH}" STREQUAL "")
foreach(__CVLIB ${OpenCV_LIB_COMPONENTS})
# We only need the "core",... part here: "opencv_core" -> "core"
STRING(REGEX REPLACE "opencv_(.*)" "\\1" __MODNAME ${__CVLIB})
INCLUDE_DIRECTORIES("${OpenCV_SOURCE_PATH}/modules/${__MODNAME}/include")
LIST(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_SOURCE_PATH}/modules/${__MODNAME}/include")
endforeach()
foreach(__cvlib ${OpenCV_REQUIRED_MODULES})
# We only need the "core",... part here: "opencv_core" -> "core"
string(REGEX REPLACE "opencv_(.*)" "\\1" __MODNAME ${__cvlib})
include_directories("${OpenCV_SOURCE_PATH}/modules/${__MODNAME}/include")
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_SOURCE_PATH}/modules/${__MODNAME}/include")
endforeach()
endif()
# For OpenCV built as static libs, we need the user to link against
# many more dependencies:
IF (NOT OpenCV_SHARED)
# Under static libs, the user of OpenCV needs access to the 3rdparty libs as well:
LINK_DIRECTORIES(@CMAKE_3RDPARTY_LIB_DIRS_CONFIGCMAKE@)
set(OpenCV_LIBS @OPENCV_LINKER_LIBS@ @IPP_LIBS@ @HIGHGUI_LIBRARIES@ ${OpenCV_LIBS})
set(OpenCV_EXTRA_COMPONENTS @JPEG_LIBRARIES@ @PNG_LIBRARIES@ @TIFF_LIBRARIES@ @JASPER_LIBRARIES@ @ZLIB_LIBRARY@)
if (WIN32 AND ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_GREATER 2.4)
# Modern CMake:
foreach(__EXTRA_LIB ${OpenCV_EXTRA_COMPONENTS})
set(OpenCV_LIBS ${OpenCV_LIBS}
debug ${__EXTRA_LIB}@OPENCV_DEBUG_POSTFIX@
optimized ${__EXTRA_LIB})
endforeach()
else()
# Old CMake:
set(OpenCV_LIBS ${OpenCV_LIBS} ${OpenCV_EXTRA_COMPONENTS})
endif()
if (APPLE)
set(OpenCV_LIBS ${OpenCV_LIBS} "-lbz2" "-framework Cocoa" "-framework QuartzCore" "-framework QTKit")
endif()
ENDIF()
# ======================================================
# ==============================================================
# Android camera helper macro
# ======================================================
IF (OpenCV_HAVE_ANDROID_CAMERA)
macro( COPY_NATIVE_CAMERA_LIBS target )
# ==============================================================
if(OpenCV_HAVE_ANDROID_CAMERA)
macro(COPY_NATIVE_CAMERA_LIBS target)
get_target_property(target_location ${target} LOCATION)
get_filename_component(target_location "${target_location}" PATH)
file(GLOB camera_wrappers "${OpenCV_LIB_DIR}/libnative_camera_r*.so")
foreach(wrapper ${camera_wrappers})
ADD_CUSTOM_COMMAND(
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${target_location}"
)
endforeach()
endmacro()
ENDIF()
endif()
# ======================================================
# Version variables:
# ======================================================
SET(OpenCV_VERSION @OPENCV_VERSION@)
SET(OpenCV_VERSION_MAJOR @OPENCV_VERSION_MAJOR@)
SET(OpenCV_VERSION_MINOR @OPENCV_VERSION_MINOR@)
SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
# ==============================================================
# Compatibility stuff
# ==============================================================
set(OpenCV_LIBRARIES ${OpenCV_LIBS})

@ -1,13 +0,0 @@
# Package Information for pkg-config
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir_old=@includedir@/opencv
includedir_new=@includedir@
Name: OpenCV
Description: Open Source Computer Vision Library
Version: @VERSION@
Libs: -L${libdir} -lopencv_core@OPENCV_DLLVERSION@ -lopencv_imgproc@OPENCV_DLLVERSION@ -lopencv_highgui@OPENCV_DLLVERSION@ -lopencv_ml@OPENCV_DLLVERSION@ -lopencv_video@OPENCV_DLLVERSION@ -lopencv_features2d@OPENCV_DLLVERSION@ -lopencv_calib3d@OPENCV_DLLVERSION@ -lopencv_objdetect@OPENCV_DLLVERSION@ -lopencv_contrib@OPENCV_DLLVERSION@ -lopencv_legacy@OPENCV_DLLVERSION@ -lopencv_flann@OPENCV_DLLVERSION@
Cflags: -I${includedir_old} -I${includedir_new}

@ -0,0 +1,9 @@
/*
* ** File generated automatically, do not modify **
*
* This file defines the list of modules available in current build configuration
*
*
*/
@OPENCV_MODULE_DEFINITIONS_CONFIGMAKE@

@ -1,10 +1,5 @@
file(GLOB ocvmodules RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
if(ocvmodules)
list(SORT ocvmodules)
if(NOT OPENCV_MODULES_PATH)
set(OPENCV_MODULES_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
foreach(mod ${ocvmodules})
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${mod}/CMakeLists.txt")
add_subdirectory("${mod}")
endif()
endforeach()
ocv_glob_modules(${OPENCV_MODULES_PATH})

@ -1,11 +1,30 @@
IF(NOT ANDROID OR NOT WITH_ANDROID_CAMERA)
return()
IF(NOT ANDROID OR ANDROID_NATIVE_API_LEVEL LESS 8)
ocv_module_disable(androidcamera)
ENDIF()
set(the_description "Auxiliary module for Android native camera support")
set(OPENCV_MODULE_TYPE STATIC)
ocv_define_module(androidcamera INTERNAL log dl)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/camera_wrapper")
set(OPENCV_ANDROIDCAMERA_MODULE_TYPE STATIC)
define_opencv_moduleEx(androidcamera INTERNAL log dl)
# Android source tree for native camera
SET (ANDROID_SOURCE_TREE "ANDROID_SOURCE_TREE-NOTFOUND" CACHE PATH
"Path to Android source tree. Set this variable to path to your Android sources to compile libnative_camera_rx.x.x.so for your Android")
SET(BUILD_ANDROID_CAMERA_WRAPPER OFF)
if(ANDROID_SOURCE_TREE)
FILE(STRINGS "${ANDROID_SOURCE_TREE}/development/sdk/platform_source.properties" ANDROID_VERSION REGEX "Platform\\.Version=[0-9]+\\.[0-9]+(\\.[0-9]+)?" )
string(REGEX REPLACE "Platform\\.Version=([0-9]+\\.[0-9]+(\\.[0-9]+)?)" "\\1" ANDROID_VERSION "${ANDROID_VERSION}")
if(ANDROID_VERSION MATCHES "^[0-9]+\\.[0-9]+$")
SET(ANDROID_VERSION "${ANDROID_VERSION}.0")
endif()
if(NOT "${ANDROID_VERSION}" STREQUAL "")
SET(BUILD_ANDROID_CAMERA_WRAPPER ON)
endif()
endif()
MARK_AS_ADVANCED(ANDROID_SOURCE_TREE)
# process wrapper libs
if (BUILD_ANDROID_CAMERA_WRAPPER)
add_subdirectory(camera_wrapper)
else()
@ -13,13 +32,12 @@ else()
foreach(wrapper ${camera_wrappers})
ADD_CUSTOM_COMMAND(
TARGET ${the_target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${LIBRARY_OUTPUT_PATH}"
)
TARGET ${the_module} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${LIBRARY_OUTPUT_PATH}"
)
get_filename_component(wrapper_name "${wrapper}" NAME)
install(FILES "${LIBRARY_OUTPUT_PATH}/${wrapper_name}"
DESTINATION ${OPENCV_LIB_INSTALL_PATH}
COMPONENT main)
DESTINATION ${OPENCV_LIB_INSTALL_PATH}
COMPONENT main)
endforeach()
endif()

@ -1 +1,2 @@
define_opencv_module(calib3d opencv_core opencv_imgproc opencv_features2d opencv_flann)
set(the_description "Camera Calibration and 3D Reconstruction")
ocv_define_module(calib3d opencv_imgproc opencv_features2d)

@ -1 +1 @@
define_opencv_module(contrib opencv_core opencv_imgproc opencv_calib3d opencv_features2d opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_flann)
ocv_define_module(contrib opencv_imgproc opencv_calib3d opencv_features2d opencv_highgui opencv_ml opencv_video opencv_objdetect)

@ -42,7 +42,6 @@
#include "precomp.hpp"
#include <stdio.h>
#include <iostream>
#include <highgui.h>
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/contrib/hybridtracker.hpp"

@ -1,7 +1,43 @@
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIR})
set(the_description "The Core Functionality")
ocv_add_module(core ${ZLIB_LIBRARY})
if(HAVE_CUDA)
file(GLOB lib_cuda "src/cuda/*.cu")
source_group("Cuda" FILES "${lib_cuda}")
include_directories(${CUDA_INCLUDE_DIRS} "${OpenCV_SOURCE_DIR}/modules/gpu/src" "${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -gencode arch=compute_10,code=sm_10
-gencode arch=compute_11,code=sm_11
-gencode arch=compute_12,code=sm_12
-gencode arch=compute_13,code=sm_13
-gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21)
OCV_CUDA_COMPILE(cuda_objs ${lib_cuda})
unset(CUDA_npp_LIBRARY CACHE)
find_cuda_helper_libs(npp)
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/zlib")
set(lib_cuda "")
set(cuda_objs "")
set(cuda_link_libs "")
endif()
ocv_glob_module_sources(SOURCES ${lib_cuda} ${cuda_objs})
if(NOT ZLIB_FOUND)
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/zlib")
endif()
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
ocv_create_module(${cuda_link_libs})
ocv_add_precompiled_headers(${the_module})
ocv_add_accuracy_tests()
ocv_add_perf_tests()
define_opencv_module(core ${ZLIB_LIBRARY})

@ -49,7 +49,7 @@
#define CV_MAJOR_VERSION 2
#define CV_MINOR_VERSION 3
#define CV_SUBMINOR_VERSION 2
#define CV_SUBMINOR_VERSION 3
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)

@ -1,2 +1,3 @@
define_opencv_module(features2d opencv_core opencv_imgproc opencv_highgui opencv_flann)
set(the_description "2D Features Framework")
ocv_define_module(features2d opencv_imgproc opencv_highgui opencv_flann)

@ -1,2 +1,3 @@
define_opencv_module(flann opencv_core)
set(the_description "Clustering and Search in Multi-Dimensional Spaces")
ocv_define_module(flann opencv_core)

@ -1,181 +1,101 @@
if(ANDROID OR IOS)
return()
ocv_module_disable(gpu)
endif()
option(OCVMODULE_GPU "Include gpu module into the OpenCV build" ON)
if(NOT OCVMODULE_GPU)
return()
endif()
set(name "gpu")
set(the_target "opencv_${name}")
project(${the_target})
set(the_description "GPU-accelerated Computer Vision")
ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect)
set(DEPS "opencv_core" "opencv_imgproc" "opencv_calib3d" "opencv_objdetect")
set(DEPS_HEADER ${DEPS} "opencv_features2d" "opencv_flann")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} opencv_gpu)
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
opencv_module_includes(${DEPS_HEADER})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
file(GLOB lib_int_hdrs "src/*.hpp" "src/*.h")
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp" "src/cuda/*.h")
file(GLOB lib_device_hdrs "src/opencv2/gpu/device/*.hpp" "src/opencv2/gpu/device/*.h")
file(GLOB lib_device_hdrs_detail "src/opencv2/gpu/device/detail/*.hpp" "src/opencv2/gpu/device/detail/*.h")
file(GLOB lib_srcs "src/*.cpp")
file(GLOB lib_cuda "src/cuda/*.cu*")
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("Include" FILES ${lib_hdrs})
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*")
file(GLOB lib_device_hdrs_detail "src/opencv2/gpu/device/detail/*.h*")
source_group("Device" FILES ${lib_device_hdrs})
source_group("Device\\Detail" FILES ${lib_device_hdrs_detail})
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()
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")
set(ncv_files ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda})
if (HAVE_CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
source_group("Src\\NVidia" FILES ${ncv_files})
include_directories("src/nvidia/core" "src/nvidia/NPP_staging" ${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-;")
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-keep")
#set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
if (APPLE)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-fno-finite-math-only;")
endif()
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 /wd4251")
foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
string(REPLACE "/W4" "/W3" ${var} "${${var}}")
endforeach()
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(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408 /wd4251")
if (BUILD_SHARED_LIBS)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-DCVAPI_EXPORTS")
endif()
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
string(REPLACE "/EHsc-" "/EHs" ${var} "${${var}}")
endforeach()
if(MSVC)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/wd4251")
endif()
# we remove -ggdb3 flag as it leads to preprocessor errors when compiling CUDA files (CUDA 4.1)
set(tmp ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "-ggdb3" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda})
set(CMAKE_CXX_DEBUG_FLAGS ${tmp})
#CUDA_BUILD_CLEAN_TARGET()
endif()
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})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} )
opencv_module_register(${the_target})
if (HAVE_CUDA)
target_link_libraries(${the_target} ${CUDA_LIBRARIES})
unset(CUDA_npp_LIBRARY CACHE)
find_cuda_helper_libs(npp)
target_link_libraries(${the_target} ${CUDA_npp_LIBRARY})
if(HAVE_CUFFT)
CUDA_ADD_CUFFT_TO_TARGET(${the_target})
endif()
if(HAVE_CUBLAS)
CUDA_ADD_CUBLAS_TO_TARGET(${the_target})
endif()
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler /wd4251)
endif()
OCV_CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda})
#CUDA_BUILD_CLEAN_TARGET()
unset(CUDA_npp_LIBRARY CACHE)
find_cuda_helper_libs(npp)
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
else()
set(lib_cuda "")
set(cuda_objs "")
set(cuda_link_libs "")
set(ncv_files "")
endif()
opencv_module_setup(${name})
install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp
ocv_set_module_sources(
HEADERS ${lib_hdrs}
SOURCES ${lib_int_hdrs} ${lib_cuda_hdrs} ${lib_device_hdrs} ${lib_device_hdrs_detail} ${lib_srcs} ${lib_cuda} ${ncv_files} ${cuda_objs}
)
ocv_create_module(${cuda_link_libs})
if(HAVE_CUDA)
if(HAVE_CUFFT)
CUDA_ADD_CUFFT_TO_TARGET(${the_module})
endif()
if(HAVE_CUBLAS)
CUDA_ADD_CUBLAS_TO_TARGET(${the_module})
endif()
install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp
DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}
COMPONENT main)
endif()
#install(FILES ${lib_device_hdrs}
# DESTINATION ${OPENCV_INCLUDE_PREFIX}/opencv2/${name}/device
# COMPONENT main)
ocv_add_precompiled_headers(${the_module})
################################################################################################################
################################ 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}")
set(test_deps opencv_${name} opencv_ts opencv_highgui opencv_calib3d ${DEPS})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/test")
opencv_module_includes(${test_deps})
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} ${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})
endif()
add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia})
# Additional target properties
set_target_properties(${the_test_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_test_target} PROPERTIES FOLDER "tests")
endif()
# 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()
add_opencv_precompiled_headers(${the_test_target})
file(GLOB test_srcs "test/*.cpp")
file(GLOB test_hdrs "test/*.hpp" "test/*.h")
if(HAVE_CUDA)
file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.hpp" "test/nvidia/*.h")
set(nvidia FILES "Src\\\\\\\\NVidia" ${nvidia}) # 8 ugly backslashes :'(
else()
set(nvidia "")
endif()
define_opencv_perf_test(${name})
ocv_add_accuracy_tests(FILES "Include" ${test_hdrs}
FILES "Src" ${test_srcs}
${nvidia})
ocv_add_perf_tests()

@ -1,21 +1,13 @@
set(the_description "High-level GUI and Media I/O")
ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_androidcamera)
# ----------------------------------------------------------------------------
# CMake file for highgui. See root CMakeLists.txt
# Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
# Jose Luis Blanco, 2008
# ----------------------------------------------------------------------------
option(OCVMODULE_HIGHGUI "Include highgui module into the OpenCV build" ON)
if(NOT OCVMODULE_HIGHGUI)
return()
endif()
set(the_target "opencv_highgui")
project(${the_target})
#so that the headers get installed.
file(GLOB lib_hdrs "include/opencv2/highgui/*.h*")
set(GRFMT_LIBS)
set(GRFMT_LIBS "")
if(WITH_PNG OR WITH_TIFF OR WITH_OPENEXR)
if(ZLIB_FOUND)
@ -85,6 +77,7 @@ set(grfmt_srcs src/bitstrm.cpp ${grfmt_srcs})
source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
set(highgui_hdrs src/precomp.hpp src/utils.hpp)
set(highgui_srcs
src/cap.cpp
src/cap_images.cpp
@ -94,15 +87,7 @@ set(highgui_srcs
src/utils.cpp
src/window.cpp
)
set(highgui_hdrs src/precomp.hpp src/utils.hpp)
#YV
set(lib_hdr_names highgui_c.h highgui.hpp)
set(highgui_ext_hdrs)
foreach(h ${lib_hdr_names})
list(APPEND highgui_ext_hdrs "${CMAKE_CURRENT_SOURCE_DIR}/include/opencv2/highgui/${h}")
endforeach()
file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
#YV
if (HAVE_QT)
@ -225,11 +210,9 @@ if(APPLE)
endif()
endif(APPLE)
if(WITH_ANDROID_CAMERA)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../androidcamera/include")
if(WITH_ANDROID_CAMERA AND OPENCV_MODULE_ANDROIDCAMERA)
set(highgui_srcs ${highgui_srcs} src/cap_android.cpp)
add_definitions(-DHAVE_ANDROID_NATIVE_CAMERA)
set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} opencv_androidcamera)
add_definitions(-DHAVE_ANDROID_NATIVE_CAMERA)#TODO: remove this line
endif()
if(HAVE_XIMEA AND XIMEA_FOUND)
@ -265,32 +248,16 @@ if(OPENCV_BUILD_3RDPARTY_LIBS AND WIN32)
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/lib")
endif()
if(COMMAND get_module_external_sources)
set( lib_srcs "${highgui_srcs}" )
set( lib_int_hdrs "${highgui_hdrs}" )
get_module_external_sources(highgui)
set( highgui_srcs "${lib_srcs}" )
set( highgui_hdrs "${lib_int_hdrs}" )
endif()
source_group("Src" FILES ${highgui_srcs} ${highgui_hdrs})
source_group("Include" FILES ${highgui_ext_hdrs})
ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs} ${highgui_hdrs} ${grfmt_srcs} ${grfmt_hdrs})
#message(STATUS "GRFMT: ${GRFMT_LIBS}")
#message(STATUS "OPENCV_LIBS: ${OPENCV_LINKER_LIBS}")
#message(STATUS "HIGHGUI_LIBS: ${HIGHGUI_LIBRARIES}")
# ----------------------------------------------------------------------------------
# Define the library target:
# ----------------------------------------------------------------------------------
opencv_module_includes(opencv_core opencv_imgproc)
ocv_module_include_directories()
if(WIN32)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/include")
endif()
add_library(${the_target} ${highgui_srcs} ${grfmt_srcs} ${highgui_hdrs} ${grfmt_hdrs} ${highgui_ext_hdrs})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core opencv_imgproc ${GRFMT_LIBS} ${HIGHGUI_LIBRARIES})
opencv_module_register(${the_target})
ocv_create_module(${GRFMT_LIBS} ${HIGHGUI_LIBRARIES})
if(BUILD_SHARED_LIBS)
add_definitions(-DHIGHGUI_EXPORTS)
@ -300,6 +267,7 @@ if(MSVC)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
opencv_module_setup(highgui)
define_opencv_test(highgui)
define_opencv_perf_test(highgui)
ocv_add_precompiled_headers(${the_module})
ocv_add_accuracy_tests()
ocv_add_perf_tests()

@ -221,7 +221,6 @@ make & enjoy!
//
//M*/
#include "highgui.h"
#include "precomp.hpp"
#if !defined WIN32 && defined HAVE_LIBV4L
@ -393,6 +392,7 @@ static void icvInitCapture_V4L() {
static int try_init_v4l(CvCaptureCAM_V4L* capture, char *deviceName)
{
// if detect = -1 then unable to open device

@ -1 +1,2 @@
define_opencv_module(imgproc opencv_core)
set(the_description "Image Processing")
ocv_define_module(imgproc opencv_core)

@ -1,21 +1,17 @@
if(NOT BUILD_JAVA_SUPPORT OR NOT PYTHON_EXECUTABLE)
return()
endif()
# ----------------------------------------------------------------------------
# CMake file for java support
# ----------------------------------------------------------------------------
project(opencv_java)
set(target opencv_java)
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp")
if(NOT BUILD_JAVA_SUPPORT OR NOT PYTHON_EXECUTABLE)
ocv_module_disable(java)
endif()
set(the_description "The java bindings")
ocv_add_module(java BINDINGS opencv_objdetect opencv_features2d opencv_imgproc opencv_video opencv_highgui opencv_ml opencv_core opencv_calib3d)
SET(OPENCV_JAVA_MODULES objdetect features2d imgproc video highgui ml core calib3d)
SET(OPENCV_EXTRA_JAVA_MODULES contrib legacy flann)
IF(WITH_ANDROID_CAMERA AND NOT BUILD_SHARED_LIBS)
LIST(APPEND OPENCV_EXTRA_JAVA_MODULES androidcamera)
ENDIF()
string(REPLACE "opencv_" "" OPENCV_JAVA_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS}")
set(target ${the_module})
include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp")
SET(GEN_JAVA "${CMAKE_CURRENT_SOURCE_DIR}/gen_java.py")
SET(HDR_PARSER "${CMAKE_CURRENT_SOURCE_DIR}/../python/src2/hdr_parser.py")
@ -81,25 +77,21 @@ foreach(module ${OPENCV_JAVA_MODULES})
endforeach()
FILE(GLOB handwrittren_cpp_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp")
FILE(GLOB handwrittren_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.h*")
FILE(GLOB handwrittren_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.h??")
FILE(GLOB handwrittren_java_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/java/*.java")
SET (generated_cpp_sources)
SET (generated_java_sources)
SET (documented_java_files)
SET (undocumented_java_files)
SET (dependent_libs)
SET (dependent_extra_libs)
foreach(module ${OPENCV_JAVA_MODULES})
LIST(APPEND generated_cpp_sources "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp")
LIST(APPEND generated_java_sources ${${module}_generated_java_sources})
LIST(APPEND dependent_libs opencv_${module})
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include")
endforeach()
# extra includes and dependencies
foreach(module ${OPENCV_EXTRA_JAVA_MODULES})
LIST(APPEND dependent_extra_libs opencv_${module})
# all needed includes
foreach(module ${OPENCV_MODULE_${the_module}_DEPS})
string(REPLACE "opencv_" "" module "${module}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../${module}/include")
endforeach()
@ -154,8 +146,8 @@ ADD_CUSTOM_TARGET(${api_target} DEPENDS ${java_files})
# add opencv_java library
add_library(${target} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources})
target_link_libraries(${target} ${dependent_libs} ${dependent_extra_libs} ${OPENCV_LINKER_LIBS})
add_dependencies(${target} ${dependent_extra_libs} ${dependent_libs} ${api_target})
target_link_libraries(${target} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
add_dependencies(${target} ${api_target})
# Additional target properties
set_target_properties(${target} PROPERTIES

@ -1 +1 @@
define_opencv_module(legacy opencv_core opencv_imgproc opencv_calib3d opencv_features2d opencv_highgui opencv_video opencv_flann)
ocv_define_module(legacy opencv_calib3d opencv_highgui opencv_video)

@ -1 +1,2 @@
define_opencv_module(ml opencv_core)
set(the_description "Machine Learning")
ocv_define_module(ml opencv_core)

@ -1 +1,2 @@
define_opencv_module(objdetect opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_calib3d opencv_flann)
set(the_description "Object Detection")
ocv_define_module(objdetect opencv_highgui opencv_calib3d)

@ -1,14 +1,16 @@
# ----------------------------------------------------------------------------
# CMake file for python support
# ----------------------------------------------------------------------------
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
return()
ocv_module_disable(python)
endif()
if(NOT PYTHONLIBS_FOUND OR NOT BUILD_NEW_PYTHON_SUPPORT OR NOT PYTHON_USE_NUMPY)
return()
ocv_module_disable(python)
endif()
# ----------------------------------------------------------------------------
# CMake file for python support
# ----------------------------------------------------------------------------
project(opencv_python)
set(the_description "The python bindings")
ocv_add_module(python BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_objdetect opencv_legacy opencv_contrib)
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(

@ -1,11 +1,3 @@
if(IOS)
return()
endif()
set(DEPS opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_flann opencv_objdetect)
if(NOT ANDROID)
set(DEPS ${DEPS} opencv_gpu)
endif()
define_opencv_module(stitching ${DEPS})
set(the_description "Images stitching")
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu)

@ -46,7 +46,8 @@
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#ifndef ANDROID
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_GPU
#include "opencv2/gpu/gpu.hpp"
#endif
@ -102,7 +103,7 @@ private:
};
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder
{
public:

@ -44,6 +44,7 @@
#define __OPENCV_STITCHING_SEAM_FINDERS_HPP__
#include "opencv2/core/core.hpp"
#include "opencv2/opencv_modules.hpp"
namespace cv {
namespace detail {
@ -114,7 +115,7 @@ private:
};
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder
{
public:

@ -45,7 +45,8 @@
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#ifndef ANDROID
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_GPU
# include "opencv2/gpu/gpu.hpp"
#endif
@ -184,7 +185,7 @@ protected:
};
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
{
public:

@ -76,7 +76,7 @@ public:
};
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
class PlaneWarperGpu: public WarperCreator
{
public:

@ -189,7 +189,7 @@ Rect FeatherBlender::createWeightMaps(const vector<Mat> &masks, const vector<Poi
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands)
{
setNumBands(num_bands);
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
#else
can_use_gpu_ = false;
@ -383,7 +383,7 @@ void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
{
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
pyr.resize(num_levels + 1);
vector<gpu::GpuMat> gpu_pyr(num_levels + 1);
@ -419,7 +419,7 @@ void restoreImageFromLaplacePyr(vector<Mat> &pyr)
void restoreImageFromLaplacePyrGpu(vector<Mat> &pyr)
{
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (pyr.empty())
return;

@ -43,9 +43,6 @@
#include "precomp.hpp"
using namespace std;
#ifndef ANDROID
using namespace cv::gpu;
#endif
namespace cv {
namespace detail {

@ -46,7 +46,7 @@ using namespace std;
using namespace cv;
using namespace cv::detail;
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
using namespace cv::gpu;
#endif
@ -127,7 +127,7 @@ private:
float match_conf_;
};
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
class GpuMatcher : public FeaturesMatcher
{
public:
@ -202,7 +202,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
LOG("1->2 & 2->1 matches: " << matches_info.matches.size() << endl);
}
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
{
matches_info.matches.clear();
@ -398,7 +398,7 @@ void OrbFeaturesFinder::find(const Mat &image, ImageFeatures &features)
}
}
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(double hess_thresh, int num_octaves, int num_layers,
int num_octaves_descr, int num_layers_descr)
{
@ -499,7 +499,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)
{
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
impl_ = new GpuMatcher(match_conf);
else

@ -46,6 +46,7 @@
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif
#include "opencv2/opencv_modules.hpp"
#include <vector>
#include <algorithm>
@ -69,11 +70,11 @@
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
# include "opencv2/gpu/gpu.hpp"
#endif
#include "modules/imgproc/src/gcgraph.hpp"
#include "../../imgproc/src/gcgraph.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
# include "opencv2/stitching/stitching_tegra.hpp"

@ -417,7 +417,7 @@ void GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
}
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
void GraphCutSeamFinderGpu::find(const vector<Mat> &src, const vector<Point> &corners,
vector<Mat> &masks)
{

@ -58,7 +58,7 @@ Stitcher Stitcher::createDefault(bool try_use_gpu)
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(try_use_gpu));
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0)
{
stitcher.setFeaturesFinder(new detail::SurfFeaturesFinderGpu());

@ -212,7 +212,7 @@ void SphericalWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_b
}
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
{
return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap);

@ -1,51 +0,0 @@
if(IOS)
return()
endif()
project(traincascade)
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}"
"${OpenCV_SOURCE_DIR}/modules/core/include"
"${OpenCV_SOURCE_DIR}/modules/imgproc/include"
"${OpenCV_SOURCE_DIR}/modules/objdetect/include"
"${OpenCV_SOURCE_DIR}/modules/ml/include"
"${OpenCV_SOURCE_DIR}/modules/highgui/include"
"${OpenCV_SOURCE_DIR}/modules/video/include"
"${OpenCV_SOURCE_DIR}/modules/features2d/include"
"${OpenCV_SOURCE_DIR}/modules/flann/include"
"${OpenCV_SOURCE_DIR}/modules/calib3d/include"
"${OpenCV_SOURCE_DIR}/modules/legacy/include"
)
set(traincascade_libs opencv_core opencv_ml opencv_imgproc
opencv_objdetect opencv_highgui opencv_haartraining_engine)
set(traincascade_files traincascade.cpp
cascadeclassifier.cpp cascadeclassifier.h
boost.cpp boost.h features.cpp traincascade_features.h
haarfeatures.cpp haarfeatures.h
lbpfeatures.cpp lbpfeatures.h
HOGfeatures.cpp HOGfeatures.h
imagestorage.cpp imagestorage.h)
set(the_target opencv_traincascade)
add_executable(${the_target} ${traincascade_files})
add_dependencies(${the_target} ${traincascade_libs})
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR lib
OUTPUT_NAME "opencv_traincascade")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "applications")
endif()
target_link_libraries(${the_target} ${traincascade_libs})
if(NOT ANDROID)
install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
endif()

@ -1,16 +1,24 @@
if(BUILD_TESTS OR BUILD_PERF_TESTS)
if(BUILD_SHARED_LIBS AND NOT MINGW)
add_definitions(-DGTEST_CREATE_SHARED_LIBRARY=1)
if (MSVC)
add_definitions( "/wd4251 /wd4275")
endif()
else()
add_definitions(-DGTEST_CREATE_SHARED_LIBRARY=0)
endif()
if(IOS)
ocv_module_disable(ts)
endif()
if(MINGW)
set(OPENCV_TS_MODULE_TYPE STATIC)
endif()
if(MINGW)
set(OPENCV_MODULE_TYPE STATIC)
endif()
set(the_description "The ts module")
ocv_add_module(ts opencv_core)
ocv_glob_module_sources()
ocv_module_include_directories()
ocv_create_module()
define_opencv_module(ts opencv_core)
if(BUILD_SHARED_LIBS AND NOT MINGW)
add_definitions(-DGTEST_CREATE_SHARED_LIBRARY=1)
if (MSVC)
add_definitions( "/wd4251 /wd4275")
endif()
else()
add_definitions(-DGTEST_CREATE_SHARED_LIBRARY=0)
endif()
ocv_add_precompiled_headers(${the_module})

@ -1 +1,2 @@
define_opencv_module(video opencv_core opencv_imgproc)
set(the_description "Video Analysis")
ocv_define_module(video opencv_imgproc)

@ -5,16 +5,8 @@
add_subdirectory(c)
add_subdirectory(cpp)
add_subdirectory(gpu)
if(NOT ANDROID)
add_subdirectory(gpu)
endif()
if(BUILD_ANDROID_EXAMPLES)
add_subdirectory(android)
endif()
if(0)
add_subdirectory(swig_python)
add_subdirectory(octave)
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
add_subdirectory(android)
endif()

@ -2,46 +2,33 @@
# CMake file for Android samples. See root CMakeLists.txt
#
# ----------------------------------------------------------------------------
SET(OPENCV_ANDROID_SAMPLES_REQUIRED_DEPS opencv_contrib opencv_legacy opencv_objdetect opencv_calib3d opencv_features2d opencv_video opencv_highgui opencv_ml opencv_imgproc opencv_flann opencv_core)
if (BUILD_ANDROID_EXAMPLES)
project(android_samples)
ocv_check_dependencies(${OPENCV_ANDROID_SAMPLES_REQUIRED_DEPS} opencv_java)
include_directories(
"${CMAKE_SOURCE_DIR}/modules/core/include"
"${CMAKE_SOURCE_DIR}/modules/flann/include"
"${CMAKE_SOURCE_DIR}/modules/imgproc/include"
"${CMAKE_SOURCE_DIR}/modules/video/include"
"${CMAKE_SOURCE_DIR}/modules/highgui/include"
"${CMAKE_SOURCE_DIR}/modules/ml/include"
"${CMAKE_SOURCE_DIR}/modules/calib3d/include"
"${CMAKE_SOURCE_DIR}/modules/features2d/include"
"${CMAKE_SOURCE_DIR}/modules/objdetect/include"
"${CMAKE_SOURCE_DIR}/modules/legacy/include"
"${CMAKE_SOURCE_DIR}/modules/contrib/include"
)
if(BUILD_ANDROID_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project(android_samples)
SET (sample_dependencies opencv_contrib opencv_legacy opencv_objdetect opencv_calib3d opencv_features2d opencv_video opencv_highgui opencv_ml opencv_imgproc opencv_flann opencv_core)
if(NOT BUILD_SHARED_LIBS)
LIST(APPEND sample_dependencies opencv_androidcamera)
endif()
foreach(m ${OPENCV_ANDROID_SAMPLES_REQUIRED_DEPS})
string(REPLACE "opencv_" "" m "${m}")
include_directories("${OpenCV_SOURCE_DIR}/modules/${m}/include")
endforeach()
file(GLOB android_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
list(REMOVE_ITEM android_samples hello-android)
list(SORT android_samples)
file(GLOB android_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
list(REMOVE_ITEM android_samples hello-android)
list(SORT android_samples)
foreach(sample ${android_samples})
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${sample}/AndroidManifest.xml")
add_android_project("${sample}" "${CMAKE_CURRENT_SOURCE_DIR}/${sample}" INSTALL)
endif()
endforeach()
#hello-android sample
ADD_EXECUTABLE(hello-android hello-android/main.cpp)
ADD_DEPENDENCIES(hello-android ${sample_dependencies})
TARGET_LINK_LIBRARIES(hello-android ${OPENCV_LINKER_LIBS} ${sample_dependencies})
set_target_properties(hello-android PROPERTIES OUTPUT_NAME hello-android RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
if(INSTALL_ANDROID_EXAMPLES)
install(TARGETS hello-android DESTINATION bin COMPONENT main)
foreach(sample ${android_samples})
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${sample}/AndroidManifest.xml")
add_android_project("${sample}" "${CMAKE_CURRENT_SOURCE_DIR}/${sample}" INSTALL)
endif()
endforeach()
#hello-android sample
ADD_EXECUTABLE(hello-android hello-android/main.cpp)
TARGET_LINK_LIBRARIES(hello-android ${OPENCV_LINKER_LIBS} ${OPENCV_ANDROID_SAMPLES_REQUIRED_DEPS})
set_target_properties(hello-android PROPERTIES OUTPUT_NAME hello-android RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
if(INSTALL_ANDROID_EXAMPLES)
install(TARGETS hello-android DESTINATION bin COMPONENT main)
endif()
endif()

@ -3,67 +3,57 @@
#
# ----------------------------------------------------------------------------
if (BUILD_EXAMPLES)
project(c_samples)
SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project(c_samples)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
include_directories(
"${CMAKE_SOURCE_DIR}/modules/core/include"
"${CMAKE_SOURCE_DIR}/modules/flann/include"
"${CMAKE_SOURCE_DIR}/modules/imgproc/include"
"${CMAKE_SOURCE_DIR}/modules/video/include"
"${CMAKE_SOURCE_DIR}/modules/highgui/include"
"${CMAKE_SOURCE_DIR}/modules/ml/include"
"${CMAKE_SOURCE_DIR}/modules/calib3d/include"
"${CMAKE_SOURCE_DIR}/modules/features2d/include"
"${CMAKE_SOURCE_DIR}/modules/objdetect/include"
"${CMAKE_SOURCE_DIR}/modules/legacy/include"
"${CMAKE_SOURCE_DIR}/modules/contrib/include"
)
ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(OPENCV_DEFINE_C_EXAMPLE name srcs)
set(the_target "example_${name}")
add_executable(${the_target} ${srcs})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_C_SAMPLES_REQUIRED_DEPS})
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(MY_DEFINE_EXAMPLE name srcs)
set(the_target "example_${name}")
add_executable(${the_target} ${srcs})
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}"
PROJECT_LABEL "(EXAMPLE) ${name}")
add_dependencies(${the_target} opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//c")
endif()
if(WIN32)
if (MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/c" COMPONENT main)
endif()
ENDMACRO(MY_DEFINE_EXAMPLE)
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}"
PROJECT_LABEL "(EXAMPLE) ${name}")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//c")
endif()
if(WIN32)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/c" COMPONENT main)
endif()
ENDMACRO()
file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.c)
file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.c)
foreach(sample_filename ${cpp_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
MY_DEFINE_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif(BUILD_EXAMPLES)
foreach(sample_filename ${cpp_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
OPENCV_DEFINE_C_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif()
if (INSTALL_C_EXAMPLES AND NOT WIN32)
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
install(FILES ${C_SAMPLES}
DESTINATION share/opencv/samples/c
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
install(FILES ${C_SAMPLES}
DESTINATION share/opencv/samples/c
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif ()

@ -3,77 +3,67 @@
#
# ----------------------------------------------------------------------------
if (BUILD_EXAMPLES)
project(cpp_samples)
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
include_directories(
"${CMAKE_SOURCE_DIR}/modules/core/include"
"${CMAKE_SOURCE_DIR}/modules/flann/include"
"${CMAKE_SOURCE_DIR}/modules/imgproc/include"
"${CMAKE_SOURCE_DIR}/modules/video/include"
"${CMAKE_SOURCE_DIR}/modules/highgui/include"
"${CMAKE_SOURCE_DIR}/modules/ml/include"
"${CMAKE_SOURCE_DIR}/modules/calib3d/include"
"${CMAKE_SOURCE_DIR}/modules/features2d/include"
"${CMAKE_SOURCE_DIR}/modules/objdetect/include"
"${CMAKE_SOURCE_DIR}/modules/legacy/include"
"${CMAKE_SOURCE_DIR}/modules/contrib/include"
"${CMAKE_SOURCE_DIR}/modules/stitching/include"
)
if (NOT ANDROID)
include_directories("${CMAKE_SOURCE_DIR}/modules/gpu/include")
endif()
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project(cpp_samples)
include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
if (HAVE_opencv_gpu)
include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(MY_DEFINE_EXAMPLE name srcs)
set(the_target "example_${name}")
add_executable(${the_target} ${srcs})
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}"
PROJECT_LABEL "(EXAMPLE) ${name}")
add_dependencies(${the_target} opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(OPENCV_DEFINE_CPP_EXAMPLE name srcs)
set(the_target "example_${name}")
add_executable(${the_target} ${srcs})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
if (HAVE_opencv_gpu)
target_link_libraries(${the_target} opencv_gpu)
endif()
if (NOT ANDROID)
target_link_libraries(${the_target} opencv_gpu)
add_dependencies(${the_target} opencv_gpu)
endif()
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}"
PROJECT_LABEL "(EXAMPLE) ${name}")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//cpp")
endif()
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//cpp")
endif()
if(WIN32)
if (MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/cpp" COMPONENT main)
endif()
ENDMACRO(MY_DEFINE_EXAMPLE)
if(WIN32)
if (MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target}
RUNTIME DESTINATION "samples/cpp" COMPONENT main)
endif()
ENDMACRO()
file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${cpp_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
MY_DEFINE_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif(BUILD_EXAMPLES)
foreach(sample_filename ${cpp_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
OPENCV_DEFINE_CPP_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif()
if (INSTALL_C_EXAMPLES AND NOT WIN32)
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
install(FILES ${C_SAMPLES}
DESTINATION share/opencv/samples/cpp
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif ()
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
install(FILES ${C_SAMPLES}
DESTINATION share/opencv/samples/cpp
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()

@ -11,14 +11,15 @@
*
*/
#include <cv.h>
#include <ml.h>
#include <cvaux.h>
#include <highgui.h>
//#include <cv.h>
//#include <ml.h>
//#include <cvaux.h>
//#include <highgui.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/hybridtracker.hpp"
using namespace cv;

@ -1,8 +1,7 @@
#include "cv.h" // include standard OpenCV headers, same as before
#include "highgui.h"
#include "ml.h"
#include <stdio.h>
#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/flann/miniflann.hpp"
using namespace cv; // all the new API is put into "cv" namespace. Export its content

@ -43,6 +43,7 @@
#include <fstream>
#include <string>
#include "opencv2/opencv_modules.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/detail/autocalib.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
@ -346,7 +347,7 @@ int main(int argc, char* argv[])
Ptr<FeaturesFinder> finder;
if (features == "surf")
{
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
finder = new SurfFeaturesFinderGpu();
else
@ -530,7 +531,7 @@ int main(int argc, char* argv[])
// Warp images and their masks
Ptr<WarperCreator> warper_creator;
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
{
if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu();
@ -582,7 +583,7 @@ int main(int argc, char* argv[])
seam_finder = new detail::VoronoiSeamFinder();
else if (seam_find_type == "gc_color")
{
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR);
else
@ -591,7 +592,7 @@ int main(int argc, char* argv[])
}
else if (seam_find_type == "gc_colorgrad")
{
#ifndef ANDROID
#ifdef HAVE_OPENCV_GPU
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR_GRAD);
else

@ -1,77 +1,69 @@
if (BUILD_EXAMPLES)
set(project "gpu")
string(TOUPPER "${project}" project_upper)
SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu)
ocv_check_dependencies(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
set(project "gpu")
string(TOUPPER "${project}" project_upper)
project("${project}_samples")
project("${project}_samples")
include_directories(
"${CMAKE_SOURCE_DIR}/modules/core/include"
"${CMAKE_SOURCE_DIR}/modules/flann/include"
"${CMAKE_SOURCE_DIR}/modules/imgproc/include"
"${CMAKE_SOURCE_DIR}/modules/video/include"
"${CMAKE_SOURCE_DIR}/modules/highgui/include"
"${CMAKE_SOURCE_DIR}/modules/ml/include"
"${CMAKE_SOURCE_DIR}/modules/calib3d/include"
"${CMAKE_SOURCE_DIR}/modules/features2d/include"
"${CMAKE_SOURCE_DIR}/modules/objdetect/include"
"${CMAKE_SOURCE_DIR}/modules/legacy/include"
"${CMAKE_SOURCE_DIR}/modules/contrib/include"
"${CMAKE_SOURCE_DIR}/modules/gpu/include"
"${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia"
"${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core"
ocv_include_modules(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
include_directories(
"${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia"
"${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core"
)
if(HAVE_CUDA)
include_directories(${CUDA_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core)
endif()
if(HAVE_CUDA)
include_directories(${CUDA_INCLUDE_DIRS} ${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia ${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(MY_DEFINE_EXAMPLE name srcs)
set(the_target "example_${project}_${name}")
add_executable(${the_target} ${srcs})
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}_${project}"
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
add_dependencies(${the_target} opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_gpu)
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
MACRO(OPENCV_DEFINE_GPU_EXAMPLE name srcs)
set(the_target "example_${project}_${name}")
add_executable(${the_target} ${srcs})
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
endif()
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
if(WIN32)
if (MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${project}" COMPONENT main)
endif()
ENDMACRO(MY_DEFINE_EXAMPLE)
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "${name}_${project}"
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
endif()
if(WIN32)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${project}" COMPONENT main)
endif()
ENDMACRO()
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${all_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
MY_DEFINE_EXAMPLE(${sample} ${sample_srcs})
endforeach()
foreach(sample_filename ${all_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
OPENCV_DEFINE_GPU_EXAMPLE(${sample} ${sample_srcs})
endforeach()
include("performance/CMakeLists.txt")
endif(BUILD_EXAMPLES)
include("performance/CMakeLists.txt")
endif()
if (NOT WIN32)
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
install(FILES ${install_list}
DESTINATION share/opencv/samples/${project}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif ()
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
install(FILES ${install_list}
DESTINATION share/opencv/samples/${project}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()

@ -6,7 +6,6 @@
#include <iostream>
#include <iomanip>
#include <cstdio>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
#ifdef HAVE_CUDA
@ -228,6 +227,7 @@ int main(int argc, const char** argv)
NCVVectorAlloc<HaarClassifierNode128> h_haarNodes(cpuCascadeAllocator, haarNumNodes);
ncvAssertPrintReturn(h_haarNodes.isMemAllocated(), "Error in cascade CPU allocator", -1);
NCVVectorAlloc<HaarFeature64> h_haarFeatures(cpuCascadeAllocator, haarNumFeatures);
ncvAssertPrintReturn(h_haarFeatures.isMemAllocated(), "Error in cascade CPU allocator", -1);
HaarClassifierCascadeDescriptor haar;

@ -11,7 +11,6 @@
#include "cvconfig.h"
#include <iostream>
#include <iomanip>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
#ifdef HAVE_CUDA

@ -4,30 +4,23 @@ file(GLOB sources "performance/*.cpp")
file(GLOB headers "performance/*.h")
add_executable(${the_target} ${sources} ${headers})
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
set_target_properties(${the_target} PROPERTIES
OUTPUT_NAME "performance_gpu"
PROJECT_LABEL "(EXAMPLE_GPU) performance")
add_dependencies(${the_target} opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu)
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_gpu)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "samples//gpu")
set_target_properties(${the_target} PROPERTIES FOLDER "samples//gpu")
endif()
if(WIN32)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/gpu" COMPONENT main)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/gpu" COMPONENT main)
endif()
if(NOT WIN32)
file(GLOB GPU_FILES performance/*.cpp performance/*.h)
install(FILES ${GPU_FILES}
DESTINATION share/opencv/samples/gpu/performance
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()
file(GLOB GPU_FILES performance/*.cpp performance/*.h)
install(FILES ${GPU_FILES}
DESTINATION share/opencv/samples/gpu/performance
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()

Loading…
Cancel
Save