Skip to content

Commit

Permalink
Support for finding ffmpeg libraries without pkg-config
Browse files Browse the repository at this point in the history
Signed-off-by: Silvio Traversaro <silvio.traversaro@iit.it>
  • Loading branch information
traversaro committed May 16, 2020
1 parent d5be066 commit ab2c08d
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
14 changes: 13 additions & 1 deletion cmake/FindAVCODEC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
########################################
# Find avcodec
include(IgnPkgConfig)
ign_pkg_check_modules(AVCODEC libavcodec)
ign_pkg_check_modules_quiet(AVCODEC libavcodec)

if(NOT AVCODEC_FOUND)
include(IgnManualSearch)
ign_manual_search(AVCODEC
HEADER_NAMES "libavcodec/avcodec.h"
LIBRARY_NAMES "avcodec")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
AVCODEC
REQUIRED_VARS AVCODEC_FOUND)
34 changes: 33 additions & 1 deletion cmake/FindAVDEVICE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,36 @@ set(av_minor ${AVDEVICE_FIND_VERSION_MINOR})
set(av_patch ${AVDEVICE_FIND_VERSION_PATCH})

include(IgnPkgConfig)
ign_pkg_check_modules(AVDEVICE "libavdevice >= ${av_major}.${av_minor}.${av_patch}")
ign_pkg_check_modules_quiet(AVDEVICE "libavdevice >= ${av_major}.${av_minor}.${av_patch}")

if(NOT AVDEVICE_FOUND)
include(IgnManualSearch)
ign_manual_search(AVDEVICE
HEADER_NAMES "libavdevice/avdevice.h"
LIBRARY_NAMES "avdevice")

# Version check
if(AVDEVICE_FOUND)
file(READ "${AVDEVICE_INCLUDE_DIRS}/libavdevice/version.h" ver_file)

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

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

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

set(AVDEVICE_VERSION "${ver_major}.${ver_minor}.${ver_patch}")

if(AVDEVICE_VERSION VERSION_LESS AVDEVICE_FIND_VERSION)
set(AVDEVICE_FOUND FALSE)
endif()
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
AVDEVICE
REQUIRED_VARS AVDEVICE_FOUND)
14 changes: 13 additions & 1 deletion cmake/FindAVFORMAT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
########################################
# Find AV format
include(IgnPkgConfig)
ign_pkg_check_modules(AVFORMAT libavformat)
ign_pkg_check_modules_quiet(AVFORMAT libavformat)

if(NOT AVFORMAT_FOUND)
include(IgnManualSearch)
ign_manual_search(AVFORMAT
HEADER_NAMES "libavformat/avformat.h"
LIBRARY_NAMES "avformat")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
AVFORMAT
REQUIRED_VARS AVFORMAT_FOUND)
14 changes: 13 additions & 1 deletion cmake/FindAVUTIL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
########################################
# Find avutil
include(IgnPkgConfig)
ign_pkg_check_modules(AVUTIL libavutil)
ign_pkg_check_modules_quiet(AVUTIL libavutil)

if(NOT AVUTIL_FOUND)
include(IgnManualSearch)
ign_manual_search(AVUTIL
HEADER_NAMES "libavutil/avutil.h"
LIBRARY_NAMES "avutil")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
AVUTIL
REQUIRED_VARS AVUTIL_FOUND)
14 changes: 13 additions & 1 deletion cmake/FindSWSCALE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@
########################################
# Find libswscale format
include(IgnPkgConfig)
ign_pkg_check_modules(SWSCALE libswscale)
ign_pkg_check_modules_quiet(SWSCALE libswscale)

if(NOT SWSCALE_FOUND)
include(IgnManualSearch)
ign_manual_search(SWSCALE
HEADER_NAMES "libswscale/swscale.h"
LIBRARY_NAMES "swscale")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
SWSCALE
REQUIRED_VARS SWSCALE_FOUND)

0 comments on commit ab2c08d

Please sign in to comment.