1set(the_description "Media I/O") 2ocv_add_module(videoio opencv_imgproc opencv_imgcodecs WRAP java python) 3 4# ---------------------------------------------------------------------------- 5# CMake file for videoio. See root CMakeLists.txt 6# Some parts taken from version of Hartmut Seichter, HIT Lab NZ. 7# Jose Luis Blanco, 2008 8# ---------------------------------------------------------------------------- 9 10if(WINRT_8_1) 11 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW") 12endif() 13 14if(APPLE) 15 ocv_include_directories(${ZLIB_INCLUDE_DIRS}) 16 list(APPEND VIDEOIO_LIBRARIES ${ZLIB_LIBRARIES}) 17endif() 18 19set(videoio_hdrs 20 ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp 21 ) 22 23set(videoio_srcs 24 ${CMAKE_CURRENT_LIST_DIR}/src/cap.cpp 25 ${CMAKE_CURRENT_LIST_DIR}/src/cap_images.cpp 26 ${CMAKE_CURRENT_LIST_DIR}/src/cap_mjpeg_encoder.cpp 27 ${CMAKE_CURRENT_LIST_DIR}/src/cap_mjpeg_decoder.cpp 28 ) 29 30file(GLOB videoio_ext_hdrs 31 "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp" 32 "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp" 33 "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h") 34 35# Removing WinRT API headers by default 36status(" ${name}: Removing WinRT API headers by default") 37list(REMOVE_ITEM videoio_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cap_winrt.hpp") 38 39# Dependencies used by the implementation referenced 40# below are not available on WinRT 8.0. 41# Enabling it for WiRT 8.1+ only. 42if(DEFINED WINRT AND NOT DEFINED WINRT_8_0) 43 44 # WinRT detected. Adding WinRT API header 45 status(" ${name}: WinRT detected. Adding WinRT API header") 46 list(APPEND videoio_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cap_winrt.hpp") 47 48 # Adding WinRT internal sources and headers 49 list(APPEND videoio_srcs 50 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_capture.cpp 51 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_bridge.cpp 52 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_video.cpp 53 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/CaptureFrameGrabber.cpp 54 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaStreamSink.cpp) 55 list(APPEND videoio_hdrs 56 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_capture.hpp 57 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_bridge.hpp 58 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_video.hpp 59 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MFIncludes.hpp 60 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/CaptureFrameGrabber.hpp 61 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaSink.hpp 62 ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaStreamSink.hpp) 63endif() 64 65if(WIN32 AND NOT ARM) 66 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_cmu.cpp) 67endif() 68 69if (WIN32 AND HAVE_DSHOW) 70 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.cpp) 71 list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.hpp) 72endif() 73 74if (WIN32 AND HAVE_MSMF) 75 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.hpp) 76 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.cpp) 77endif() 78 79if (WIN32 AND HAVE_VFW) 80 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_vfw.cpp) 81endif() 82 83if(HAVE_XINE) 84 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_xine.cpp) 85endif(HAVE_XINE) 86 87if(HAVE_DC1394_2) 88 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394_v2.cpp) 89endif(HAVE_DC1394_2) 90 91if(HAVE_DC1394) 92 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394.cpp) 93endif(HAVE_DC1394) 94 95if(HAVE_GSTREAMER) 96 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp) 97endif(HAVE_GSTREAMER) 98 99if(HAVE_UNICAP) 100 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_unicap.cpp) 101endif(HAVE_UNICAP) 102 103if(HAVE_LIBV4L) 104 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libv4l.cpp) 105elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO) 106 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_v4l.cpp) 107endif() 108 109if(HAVE_OPENNI) 110 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_openni.cpp) 111 ocv_include_directories(${OPENNI_INCLUDE_DIR}) 112 list(APPEND VIDEOIO_LIBRARIES ${OPENNI_LIBRARY}) 113endif(HAVE_OPENNI) 114 115if(HAVE_OPENNI2) 116 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_openni2.cpp) 117 ocv_include_directories(${OPENNI2_INCLUDE_DIR}) 118 list(APPEND VIDEOIO_LIBRARIES ${OPENNI2_LIBRARY}) 119endif(HAVE_OPENNI2) 120 121if(HAVE_XIMEA) 122 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ximea.cpp) 123 if(XIMEA_PATH) 124 ocv_include_directories(${XIMEA_PATH}) 125 endif() 126 if(XIMEA_LIBRARY_DIR) 127 link_directories("${XIMEA_LIBRARY_DIR}") 128 endif() 129 if(WIN32 AND X86_64) 130 list(APPEND VIDEOIO_LIBRARIES m3apiX64) 131 elseif(APPLE) 132 list(APPEND VIDEOIO_LIBRARIES "-framework m3api") 133 else() 134 list(APPEND VIDEOIO_LIBRARIES m3api) 135 endif() 136endif(HAVE_XIMEA) 137 138if(HAVE_FFMPEG) 139 list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ffmpeg_impl.hpp) 140 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ffmpeg.cpp) 141 if(UNIX AND BZIP2_LIBRARIES) 142 list(APPEND VIDEOIO_LIBRARIES ${BZIP2_LIBRARIES}) 143 endif() 144 if(APPLE) 145 list(APPEND VIDEOIO_LIBRARIES "-framework VideoDecodeAcceleration" bz2) 146 endif() 147endif(HAVE_FFMPEG) 148 149if(HAVE_PVAPI) 150 add_definitions(-DHAVE_PVAPI) 151 add_definitions(${PVAPI_DEFINITIONS}) 152 ocv_include_directories(${PVAPI_INCLUDE_PATH}) 153 set(videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_pvapi.cpp ${videoio_srcs}) 154 list(APPEND VIDEOIO_LIBRARIES ${PVAPI_LIBRARY}) 155endif() 156 157if(HAVE_GIGE_API) 158 add_definitions(-DHAVE_GIGE_API) 159 ocv_include_directories(${GIGEAPI_INCLUDE_PATH}) 160 set(videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_giganetix.cpp ${videoio_srcs}) 161 list(APPEND VIDEOIO_LIBRARIES ${GIGEAPI_LIBRARIES}) 162 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_giganetix.cpp) 163endif(HAVE_GIGE_API) 164 165if(HAVE_AVFOUNDATION) 166 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm) 167 list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore") 168endif() 169 170if(HAVE_QUICKTIME) 171 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_qt.cpp) 172 list(APPEND VIDEOIO_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore") 173elseif(HAVE_QTKIT) 174 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_qtkit.mm) 175 list(APPEND VIDEOIO_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit") 176endif() 177 178if(HAVE_INTELPERC) 179 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_intelperc.cpp) 180 ocv_include_directories(${INTELPERC_INCLUDE_DIR}) 181 list(APPEND VIDEOIO_LIBRARIES ${INTELPERC_LIBRARIES}) 182endif(HAVE_INTELPERC) 183 184if(HAVE_GPHOTO2) 185 list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gphoto2.cpp) 186endif(HAVE_GPHOTO2) 187 188if(IOS) 189 add_definitions(-DHAVE_IOS=1) 190 list(APPEND videoio_srcs 191 ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_abstract_camera.mm 192 ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_photo_camera.mm 193 ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_video_camera.mm) 194 list(APPEND VIDEOIO_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary") 195endif() 196 197if(WIN32) 198 link_directories("${OpenCV_SOURCE_DIR}/3rdparty/lib") # for ffmpeg wrapper only 199 include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include") # for directshow in VS2005 and multi-monitor support on MinGW 200 include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include/ffmpeg_") # for tests 201endif() 202 203if(UNIX) 204 #these variables are set by CHECK_MODULE macro 205 foreach(P ${VIDEOIO_INCLUDE_DIRS}) 206 ocv_include_directories(${P}) 207 endforeach() 208 209 foreach(P ${VIDEOIO_LIBRARY_DIRS}) 210 link_directories(${P}) 211 endforeach() 212endif() 213 214source_group("Src" FILES ${videoio_srcs} ${videoio_hdrs}) 215source_group("Include" FILES ${videoio_ext_hdrs}) 216ocv_set_module_sources(HEADERS ${videoio_ext_hdrs} SOURCES ${videoio_srcs} ${videoio_hdrs}) 217ocv_module_include_directories() 218 219ocv_create_module(${VIDEOIO_LIBRARIES}) 220 221macro(ocv_videoio_configure_target) 222if(APPLE) 223 add_apple_compiler_options(the_module) 224endif() 225 226if(BUILD_SHARED_LIBS) 227 add_definitions(-DVIDEOIO_EXPORTS) 228endif() 229 230if(MSVC) 231 set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG") 232endif() 233 234#stop automatic dependencies propagation for this module 235if(NOT BUILD_opencv_world) 236 set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") 237endif() 238 239ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations) 240 241if(WIN32 AND WITH_FFMPEG) 242 #copy ffmpeg dll to the output folder 243 if(MSVC64 OR MINGW64) 244 set(FFMPEG_SUFFIX _64) 245 endif() 246 247 set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll") 248 set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll") 249 set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}") 250 251 if(MSVC_IDE) 252 add_custom_command(TARGET ${the_module} POST_BUILD 253 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}" 254 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}" 255 COMMENT "Copying ${ffmpeg_path} to the output directory") 256 elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual")) 257 add_custom_command(TARGET ${the_module} POST_BUILD 258 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}" 259 COMMENT "Copying ${ffmpeg_path} to the output directory") 260 else() 261 add_custom_command(TARGET ${the_module} POST_BUILD 262 COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}" 263 COMMENT "Copying ${ffmpeg_path} to the output directory") 264 endif() 265 266 install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}") 267endif() 268endmacro() 269 270if(NOT BUILD_opencv_world) 271 ocv_videoio_configure_target() 272endif() 273 274ocv_add_accuracy_tests() 275ocv_add_perf_tests() 276