Skip to content

Commit

Permalink
Fix FindAVDEVICE.cmake in case without pkg-config installed with ffmp…
Browse files Browse the repository at this point in the history
…eg >= 5.1 (#330)

* Fix FindAVDEVICE.cmake in case without pkg-config

Signed-off-by: Silvio <[email protected]>
  • Loading branch information
traversaro authored Dec 22, 2022
1 parent 99a5641 commit 4aa9523
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmake/FindAVDEVICE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ if(NOT AVDEVICE_FOUND)
if(AVDEVICE_FOUND)
file(READ "${AVDEVICE_INCLUDE_DIRS}/libavdevice/version.h" ver_file)

# ffmpeg 5.1 splitted version information in two files
# https://github.com/FFmpeg/FFmpeg/commit/884c5976592c2d8084e8c9951c94ddf04019d81d
if(EXISTS "${AVDEVICE_INCLUDE_DIRS}/libavdevice/version_major.h")
file(READ "${AVDEVICE_INCLUDE_DIRS}/libavdevice/version_major.h" ver_major_file)
string(CONCAT ver_file ${ver_file} ${ver_major_file})
endif()

string(REGEX MATCH "LIBAVDEVICE_VERSION_MAJOR[ \t\r\n]+([0-9]*)" _ ${ver_file})
set(ver_major ${CMAKE_MATCH_1})

Expand All @@ -52,4 +59,4 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
AVDEVICE
REQUIRED_VARS AVDEVICE_FOUND)
REQUIRED_VARS AVDEVICE_FOUND)

0 comments on commit 4aa9523

Please sign in to comment.