Home | History | Annotate | Download | only in videoio
      1 set(the_description "Media I/O")
      2 ocv_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 
     10 if(WINRT_8_1)
     11   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
     12 endif()
     13 
     14 if(APPLE)
     15   ocv_include_directories(${ZLIB_INCLUDE_DIRS})
     16   list(APPEND VIDEOIO_LIBRARIES ${ZLIB_LIBRARIES})
     17 endif()
     18 
     19 set(videoio_hdrs
     20     ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp
     21     )
     22 
     23 set(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 
     30 file(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
     36 status("  ${name}: Removing WinRT API headers by default")
     37 list(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.
     42 if(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)
     63 endif()
     64 
     65 if(WIN32 AND NOT ARM)
     66   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_cmu.cpp)
     67 endif()
     68 
     69 if (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)
     72 endif()
     73 
     74 if (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)
     77 endif()
     78 
     79 if (WIN32 AND HAVE_VFW)
     80   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_vfw.cpp)
     81 endif()
     82 
     83 if(HAVE_XINE)
     84   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_xine.cpp)
     85 endif(HAVE_XINE)
     86 
     87 if(HAVE_DC1394_2)
     88   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394_v2.cpp)
     89 endif(HAVE_DC1394_2)
     90 
     91 if(HAVE_DC1394)
     92   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394.cpp)
     93 endif(HAVE_DC1394)
     94 
     95 if(HAVE_GSTREAMER)
     96   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp)
     97 endif(HAVE_GSTREAMER)
     98 
     99 if(HAVE_UNICAP)
    100   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_unicap.cpp)
    101 endif(HAVE_UNICAP)
    102 
    103 if(HAVE_LIBV4L)
    104   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libv4l.cpp)
    105 elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
    106   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_v4l.cpp)
    107 endif()
    108 
    109 if(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})
    113 endif(HAVE_OPENNI)
    114 
    115 if(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})
    119 endif(HAVE_OPENNI2)
    120 
    121 if(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()
    136 endif(HAVE_XIMEA)
    137 
    138 if(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()
    147 endif(HAVE_FFMPEG)
    148 
    149 if(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})
    155 endif()
    156 
    157 if(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)
    163 endif(HAVE_GIGE_API)
    164 
    165 if(HAVE_AVFOUNDATION)
    166   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm)
    167   list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore")
    168 endif()
    169 
    170 if(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")
    173 elseif(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")
    176 endif()
    177 
    178 if(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})
    182 endif(HAVE_INTELPERC)
    183 
    184 if(HAVE_GPHOTO2)
    185   list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gphoto2.cpp)
    186 endif(HAVE_GPHOTO2)
    187 
    188 if(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")
    195 endif()
    196 
    197 if(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
    201 endif()
    202 
    203 if(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()
    212 endif()
    213 
    214 source_group("Src" FILES ${videoio_srcs} ${videoio_hdrs})
    215 source_group("Include" FILES ${videoio_ext_hdrs})
    216 ocv_set_module_sources(HEADERS ${videoio_ext_hdrs} SOURCES ${videoio_srcs} ${videoio_hdrs})
    217 ocv_module_include_directories()
    218 
    219 ocv_create_module(${VIDEOIO_LIBRARIES})
    220 
    221 macro(ocv_videoio_configure_target)
    222 if(APPLE)
    223   add_apple_compiler_options(the_module)
    224 endif()
    225 
    226 if(BUILD_SHARED_LIBS)
    227   add_definitions(-DVIDEOIO_EXPORTS)
    228 endif()
    229 
    230 if(MSVC)
    231   set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
    232 endif()
    233 
    234 #stop automatic dependencies propagation for this module
    235 if(NOT BUILD_opencv_world)
    236   set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
    237 endif()
    238 
    239 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
    240 
    241 if(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}")
    267 endif()
    268 endmacro()
    269 
    270 if(NOT BUILD_opencv_world)
    271   ocv_videoio_configure_target()
    272 endif()
    273 
    274 ocv_add_accuracy_tests()
    275 ocv_add_perf_tests()
    276