Skip to content

Commit 16e03cd

Browse files
rusloNeroBurner
authored andcommitted
hunter: add package FFmpeg
Also includes commit: hunter: update ffmpeg hunterizations (see detect_ffmpeg.cmake) Co-Author: Akhil Kumar <[email protected]>
1 parent f12c0cf commit 16e03cd

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

cmake/templates/OpenCVConfig.cmake.in

+4
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ if("@OPENEXR_FOUND@")
388388
find_dependency(OpenEXR CONFIG)
389389
endif()
390390

391+
if("@WITH_FFMPEG@")
392+
find_dependency(ffmpeg CONFIG)
393+
endif()
394+
391395
# AWP: Qt5 dependencies -- start
392396
if("@Qt5Core_FOUND@")
393397
find_dependency(Qt5Core)

modules/videoio/cmake/detect_ffmpeg.cmake

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
# --- FFMPEG ---
2-
OCV_OPTION(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE "Include FFMPEG/libavdevice library support." OFF
3-
VISIBLE_IF WITH_FFMPEG)
4-
52
if(NOT HAVE_FFMPEG AND OPENCV_FFMPEG_USE_FIND_PACKAGE)
3+
if(NOT HUNTER_ENABLED) ### NO INDENT
64
if(OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "1" OR OPENCV_FFMPEG_USE_FIND_PACKAGE STREQUAL "ON")
75
set(OPENCV_FFMPEG_USE_FIND_PACKAGE "FFMPEG")
86
endif()
97
find_package(${OPENCV_FFMPEG_USE_FIND_PACKAGE}) # Required components: AVCODEC AVFORMAT AVUTIL SWSCALE
108
if(FFMPEG_FOUND OR FFmpeg_FOUND)
119
set(HAVE_FFMPEG TRUE)
1210
endif()
11+
12+
else(HUNTER_ENABLED) ### NO INDENT
13+
hunter_add_package(ffmpeg)
14+
find_package(ffmpeg CONFIG REQUIRED)
15+
16+
set(FFMPEG_FOUND TRUE)
17+
set(HAVE_FFMPEG TRUE)
18+
foreach(lib avcodec avformat avutil swresample swscale)
19+
get_target_property(
20+
${lib}_INCLUDE_DIR
21+
ffmpeg::${lib}
22+
INTERFACE_INCLUDE_DIRECTORIES
23+
)
24+
list(APPEND FFMPEG_INCLUDE_DIRS "${${lib}_INCLUDE_DIR}")
25+
list(APPEND FFMPEG_LIBRARIES "ffmpeg::${lib}")
26+
set(FFMPEG_lib${lib}_FOUND TRUE)
27+
endforeach()
28+
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
29+
endif()
1330
endif()
1431

1532
if(NOT HAVE_FFMPEG AND WIN32 AND NOT ARM AND NOT OPENCV_FFMPEG_SKIP_DOWNLOAD)
@@ -32,13 +49,6 @@ if(NOT HAVE_FFMPEG AND PKG_CONFIG_FOUND)
3249
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_libavresample_LIBRARIES})
3350
list(APPEND _used_ffmpeg_libraries libavresample)
3451
endif()
35-
if(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE)
36-
ocv_check_modules(FFMPEG_libavdevice libavdevice) # optional
37-
if(FFMPEG_libavdevice_FOUND)
38-
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_libavdevice_LIBRARIES})
39-
list(APPEND _used_ffmpeg_libraries libavdevice)
40-
endif()
41-
endif()
4252
set(HAVE_FFMPEG TRUE)
4353
else()
4454
set(_missing_ffmpeg_libraries "")
@@ -61,7 +71,6 @@ if(HAVE_FFMPEG AND NOT HAVE_FFMPEG_WRAPPER)
6171
set(_min_libavutil_version 52.3.0)
6272
set(_min_libswscale_version 2.1.1)
6373
set(_min_libavresample_version 1.0.1)
64-
set(_min_libavdevice_version 53.2.0)
6574
foreach(ffmpeg_lib ${_used_ffmpeg_libraries})
6675
if(FFMPEG_${ffmpeg_lib}_VERSION VERSION_LESS _min_${ffmpeg_lib}_version)
6776
message(STATUS "FFMPEG is disabled. Can't find suitable ${ffmpeg_lib} library"
@@ -78,7 +87,6 @@ if(HAVE_FFMPEG AND NOT HAVE_FFMPEG_WRAPPER)
7887
unset(_min_libavutil_version)
7988
unset(_min_libswscale_version)
8089
unset(_min_libavresample_version)
81-
unset(_min_libavdevice_version)
8290
endif()
8391

8492
#==================================
@@ -88,7 +96,7 @@ if(HAVE_FFMPEG AND NOT HAVE_FFMPEG_WRAPPER AND NOT OPENCV_FFMPEG_SKIP_BUILD_CHEC
8896
"${OpenCV_BINARY_DIR}"
8997
"${OpenCV_SOURCE_DIR}/cmake/checks/ffmpeg_test.cpp"
9098
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${FFMPEG_INCLUDE_DIRS}"
91-
"-DLINK_LIBRARIES:STRING=${FFMPEG_LIBRARIES}"
99+
LINK_LIBRARIES ${FFMPEG_LIBRARIES}
92100
OUTPUT_VARIABLE TRY_OUT
93101
)
94102
if(NOT __VALID_FFMPEG)
@@ -105,12 +113,7 @@ unset(_used_ffmpeg_libraries)
105113
if(HAVE_FFMPEG_WRAPPER)
106114
ocv_add_external_target(ffmpeg "" "" "HAVE_FFMPEG_WRAPPER")
107115
elseif(HAVE_FFMPEG)
108-
if(OPENCV_FFMPEG_ENABLE_LIBAVDEVICE AND FFMPEG_libavdevice_FOUND)
109-
set(HAVE_FFMPEG_LIBAVDEVICE TRUE)
110-
ocv_add_external_target(ffmpeg "${FFMPEG_INCLUDE_DIRS}" "${FFMPEG_LIBRARIES}" "HAVE_FFMPEG;HAVE_FFMPEG_LIBAVDEVICE")
111-
else()
112-
ocv_add_external_target(ffmpeg "${FFMPEG_INCLUDE_DIRS}" "${FFMPEG_LIBRARIES}" "HAVE_FFMPEG")
113-
endif()
116+
ocv_add_external_target(ffmpeg "${FFMPEG_INCLUDE_DIRS}" "${FFMPEG_LIBRARIES}" "HAVE_FFMPEG")
114117
set(__builtin_defines "")
115118
set(__builtin_include_dirs "")
116119
set(__builtin_libs "")

0 commit comments

Comments
 (0)