From fc1a3ae2876d939a4b47be61ae9e32f4d7abfa2d Mon Sep 17 00:00:00 2001 From: David Hirvonen Date: Thu, 25 Apr 2019 12:00:54 -0400 Subject: [PATCH] manage ffmpeg dependency w/ hunter This adds support for ffmpeg as a hunter package w/ appropriate options: `-DWITH_FFMPEG=ON -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON` * update Hunter release * update HunterGate * enable ffmpeg package w/ `if(HUNTER_ENABLED)` * translate ffmpeg CONFIG libs to CMake's variable style usage, i.e. `${FFMPEG_INCLUDE_DIRS}, ${FFMPEG_LIBRARIES}` --- cmake/OpenCVFindLibsVideo.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake index 4f6b04247379..565db9af082e 100644 --- a/cmake/OpenCVFindLibsVideo.cmake +++ b/cmake/OpenCVFindLibsVideo.cmake @@ -186,6 +186,8 @@ endif(WITH_XIMEA) ocv_clear_vars(HAVE_FFMPEG) if(WITH_FFMPEG) # try FFmpeg autodetection if(OPENCV_FFMPEG_USE_FIND_PACKAGE) + if(NOT HUNTER_ENABLED) + if(OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "1" OR OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "ON") set(OPENCV_FFMPEG_USE_FIND_PACKAGE "FFMPEG") endif() @@ -195,6 +197,23 @@ if(WITH_FFMPEG) # try FFmpeg autodetection else() message(STATUS "Can't find FFmpeg via find_package(${OPENCV_FFMPEG_USE_FIND_PACKAGE})") endif() + + else(HUNTER_ENABLED) + hunter_add_package(ffmpeg) + find_package(ffmpeg CONFIG REQUIRED) + + set(FFMPEG_FOUND TRUE) + foreach(lib avcodec avformat avutil swresample swscale) + get_target_property( + ${lib}_INCLUDE_DIR + ffmpeg::${lib} + INTERFACE_INCLUDE_DIRECTORIES + ) + list(APPEND FFMPEG_INCLUDE_DIRS "${${lib}_INCLUDE_DIR}") + list(APPEND FFMPEG_LIBRARIES "ffmpeg::${lib}") + endforeach() + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) + endif() elseif(WIN32 AND NOT ARM AND NOT OPENCV_FFMPEG_SKIP_DOWNLOAD) include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg.cmake") download_win_ffmpeg(FFMPEG_CMAKE_SCRIPT)