CMakeLists.txt 9.96 KB
Newer Older
1
set(the_description "Media I/O")
2
ocv_add_module(videoio opencv_imgproc opencv_imgcodecs WRAP java python)
3 4 5 6 7 8 9

# ----------------------------------------------------------------------------
#  CMake file for videoio. See root CMakeLists.txt
#   Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
#   Jose Luis Blanco, 2008
# ----------------------------------------------------------------------------

10
if(WINRT_8_1)
11 12 13 14 15 16 17 18 19
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
endif()

if(APPLE)
  ocv_include_directories(${ZLIB_INCLUDE_DIRS})
  list(APPEND VIDEOIO_LIBRARIES ${ZLIB_LIBRARIES})
endif()

set(videoio_hdrs
Alexander Alekhin's avatar
Alexander Alekhin committed
20
    ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
21 22 23
    )

set(videoio_srcs
Alexander Alekhin's avatar
Alexander Alekhin committed
24 25
    ${CMAKE_CURRENT_LIST_DIR}/src/cap.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/cap_images.cpp
26 27
    ${CMAKE_CURRENT_LIST_DIR}/src/cap_mjpeg_encoder.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/cap_mjpeg_decoder.cpp
28 29
    )

Alexander Alekhin's avatar
Alexander Alekhin committed
30 31 32 33
file(GLOB videoio_ext_hdrs
    "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
    "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
    "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h")
34

35 36 37 38 39 40 41 42 43
# Removing WinRT API headers by default
list(REMOVE_ITEM videoio_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cap_winrt.hpp")

# Dependencies used by the implementation referenced
# below are not available on WinRT 8.0.
# Enabling it for WiRT 8.1+ only.
if(DEFINED WINRT AND NOT DEFINED WINRT_8_0)

    # WinRT detected. Adding WinRT API header
44
    message(STATUS "  ${name}: WinRT detected. Adding WinRT API header")
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    list(APPEND videoio_ext_hdrs "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cap_winrt.hpp")

    # Adding WinRT internal sources and headers
    list(APPEND videoio_srcs
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_capture.cpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_bridge.cpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_video.cpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/CaptureFrameGrabber.cpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaStreamSink.cpp)
    list(APPEND videoio_hdrs
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_capture.hpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_bridge.hpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt_video.hpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MFIncludes.hpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/CaptureFrameGrabber.hpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaSink.hpp
        ${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaStreamSink.hpp)
endif()

64
if(WIN32 AND NOT ARM)
Alexander Alekhin's avatar
Alexander Alekhin committed
65
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_cmu.cpp)
66 67 68
endif()

if (WIN32 AND HAVE_DSHOW)
Alexander Alekhin's avatar
Alexander Alekhin committed
69 70
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.cpp)
  list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.hpp)
71 72 73
endif()

if (WIN32 AND HAVE_MSMF)
74
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.hpp)
Alexander Alekhin's avatar
Alexander Alekhin committed
75
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.cpp)
76 77 78
endif()

if (WIN32 AND HAVE_VFW)
Alexander Alekhin's avatar
Alexander Alekhin committed
79
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_vfw.cpp)
80 81 82
endif()

if(HAVE_XINE)
Alexander Alekhin's avatar
Alexander Alekhin committed
83
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_xine.cpp)
84 85 86
endif(HAVE_XINE)

if(HAVE_DC1394_2)
Alexander Alekhin's avatar
Alexander Alekhin committed
87
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394_v2.cpp)
88 89 90
endif(HAVE_DC1394_2)

if(HAVE_DC1394)
Alexander Alekhin's avatar
Alexander Alekhin committed
91
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394.cpp)
92 93 94
endif(HAVE_DC1394)

if(HAVE_GSTREAMER)
Alexander Alekhin's avatar
Alexander Alekhin committed
95
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp)
96 97 98
endif(HAVE_GSTREAMER)

if(HAVE_UNICAP)
Alexander Alekhin's avatar
Alexander Alekhin committed
99
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_unicap.cpp)
100 101 102
endif(HAVE_UNICAP)

if(HAVE_LIBV4L)
Alexander Alekhin's avatar
Alexander Alekhin committed
103
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libv4l.cpp)
104
elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
Alexander Alekhin's avatar
Alexander Alekhin committed
105
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_v4l.cpp)
106 107 108
endif()

if(HAVE_OPENNI)
Alexander Alekhin's avatar
Alexander Alekhin committed
109
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_openni.cpp)
110 111 112 113
  ocv_include_directories(${OPENNI_INCLUDE_DIR})
  list(APPEND VIDEOIO_LIBRARIES ${OPENNI_LIBRARY})
endif(HAVE_OPENNI)

Lars Glud's avatar
Lars Glud committed
114
if(HAVE_OPENNI2)
Alexander Alekhin's avatar
Alexander Alekhin committed
115
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_openni2.cpp)
Lars Glud's avatar
Lars Glud committed
116 117 118 119
  ocv_include_directories(${OPENNI2_INCLUDE_DIR})
  list(APPEND VIDEOIO_LIBRARIES ${OPENNI2_LIBRARY})
endif(HAVE_OPENNI2)

120
if(HAVE_XIMEA)
Alexander Alekhin's avatar
Alexander Alekhin committed
121
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ximea.cpp)
122 123 124
  if(XIMEA_PATH)
    ocv_include_directories(${XIMEA_PATH})
  endif()
125 126 127
  if(XIMEA_LIBRARY_DIR)
    link_directories("${XIMEA_LIBRARY_DIR}")
  endif()
128
  if(WIN32 AND X86_64)
129
    list(APPEND VIDEOIO_LIBRARIES m3apiX64)
130 131
  elseif(APPLE)
    list(APPEND VIDEOIO_LIBRARIES "-framework m3api")
132 133 134 135 136 137
  else()
    list(APPEND VIDEOIO_LIBRARIES m3api)
  endif()
endif(HAVE_XIMEA)

if(HAVE_FFMPEG)
138 139
  list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ffmpeg_impl.hpp)
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ffmpeg.cpp)
140 141 142 143 144 145 146 147 148 149 150 151
  if(UNIX AND BZIP2_LIBRARIES)
    list(APPEND VIDEOIO_LIBRARIES ${BZIP2_LIBRARIES})
  endif()
  if(APPLE)
    list(APPEND VIDEOIO_LIBRARIES "-framework VideoDecodeAcceleration" bz2)
  endif()
endif(HAVE_FFMPEG)

if(HAVE_PVAPI)
  add_definitions(-DHAVE_PVAPI)
  add_definitions(${PVAPI_DEFINITIONS})
  ocv_include_directories(${PVAPI_INCLUDE_PATH})
Alexander Alekhin's avatar
Alexander Alekhin committed
152
  set(videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_pvapi.cpp ${videoio_srcs})
153 154 155 156 157 158
  list(APPEND VIDEOIO_LIBRARIES ${PVAPI_LIBRARY})
endif()

if(HAVE_GIGE_API)
  add_definitions(-DHAVE_GIGE_API)
  ocv_include_directories(${GIGEAPI_INCLUDE_PATH})
Alexander Alekhin's avatar
Alexander Alekhin committed
159
  set(videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_giganetix.cpp ${videoio_srcs})
160
  list(APPEND VIDEOIO_LIBRARIES ${GIGEAPI_LIBRARIES})
Alexander Alekhin's avatar
Alexander Alekhin committed
161
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_giganetix.cpp)
162 163 164
endif(HAVE_GIGE_API)

if(HAVE_AVFOUNDATION)
Alexander Alekhin's avatar
Alexander Alekhin committed
165
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm)
166 167 168 169
  list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
endif()

if(HAVE_QUICKTIME)
Alexander Alekhin's avatar
Alexander Alekhin committed
170
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_qt.cpp)
171 172
  list(APPEND VIDEOIO_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore")
elseif(HAVE_QTKIT)
Alexander Alekhin's avatar
Alexander Alekhin committed
173
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_qtkit.mm)
174 175 176 177
  list(APPEND VIDEOIO_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit")
endif()

if(HAVE_INTELPERC)
Alexander Alekhin's avatar
Alexander Alekhin committed
178
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_intelperc.cpp)
179 180 181 182
  ocv_include_directories(${INTELPERC_INCLUDE_DIR})
  list(APPEND VIDEOIO_LIBRARIES ${INTELPERC_LIBRARIES})
endif(HAVE_INTELPERC)

183 184 185 186
if(HAVE_GPHOTO2)
  list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gphoto2.cpp)
endif(HAVE_GPHOTO2)

187 188
if(IOS)
  add_definitions(-DHAVE_IOS=1)
Alexander Alekhin's avatar
Alexander Alekhin committed
189 190 191 192
  list(APPEND videoio_srcs
       ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_abstract_camera.mm
       ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_photo_camera.mm
       ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_video_camera.mm)
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
  list(APPEND VIDEOIO_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
endif()

if(WIN32)
  link_directories("${OpenCV_SOURCE_DIR}/3rdparty/lib") # for ffmpeg wrapper only
  include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include") # for directshow in VS2005 and multi-monitor support on MinGW
  include_directories(AFTER SYSTEM "${OpenCV_SOURCE_DIR}/3rdparty/include/ffmpeg_") # for tests
endif()

if(UNIX)
  #these variables are set by CHECK_MODULE macro
  foreach(P ${VIDEOIO_INCLUDE_DIRS})
    ocv_include_directories(${P})
  endforeach()

  foreach(P ${VIDEOIO_LIBRARY_DIRS})
    link_directories(${P})
  endforeach()
endif()

source_group("Src" FILES ${videoio_srcs} ${videoio_hdrs})
source_group("Include" FILES ${videoio_ext_hdrs})
ocv_set_module_sources(HEADERS ${videoio_ext_hdrs} SOURCES ${videoio_srcs} ${videoio_hdrs})
ocv_module_include_directories()

ocv_create_module(${VIDEOIO_LIBRARIES})

Alexander Alekhin's avatar
Alexander Alekhin committed
220
macro(ocv_videoio_configure_target)
221
if(APPLE)
222
  add_apple_compiler_options(the_module)
223 224 225 226 227 228 229 230 231 232 233
endif()

if(BUILD_SHARED_LIBS)
  add_definitions(-DVIDEOIO_EXPORTS)
endif()

if(MSVC)
  set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()

#stop automatic dependencies propagation for this module
Alexander Alekhin's avatar
Alexander Alekhin committed
234 235 236
if(NOT BUILD_opencv_world)
  set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
endif()
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266

ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)

if(WIN32 AND WITH_FFMPEG)
  #copy ffmpeg dll to the output folder
  if(MSVC64 OR MINGW64)
    set(FFMPEG_SUFFIX _64)
  endif()

  set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
  set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
  set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")

  if(MSVC_IDE)
    add_custom_command(TARGET ${the_module} POST_BUILD
                       COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}"
                       COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}"
                       COMMENT "Copying ${ffmpeg_path} to the output directory")
  elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual"))
    add_custom_command(TARGET ${the_module} POST_BUILD
                       COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}"
                       COMMENT "Copying ${ffmpeg_path} to the output directory")
  else()
    add_custom_command(TARGET ${the_module} POST_BUILD
                       COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
                       COMMENT "Copying ${ffmpeg_path} to the output directory")
  endif()

  install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
endif()
Alexander Alekhin's avatar
Alexander Alekhin committed
267 268 269 270 271
endmacro()

if(NOT BUILD_opencv_world)
  ocv_videoio_configure_target()
endif()
272 273 274

ocv_add_accuracy_tests()
ocv_add_perf_tests()