2023-10-07 03:01:35 -06:00
|
|
|
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
|
|
|
|
#
|
|
|
|
# Once done this will define
|
|
|
|
# FFMPEG_FOUND - System has the all required components.
|
|
|
|
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
|
|
|
|
#
|
|
|
|
# For each of the components it will additionally set.
|
|
|
|
# - AVCODEC
|
|
|
|
# - AVDEVICE
|
|
|
|
# - AVFORMAT
|
|
|
|
# - AVFILTER
|
|
|
|
# - AVUTIL
|
|
|
|
# - POSTPROC
|
|
|
|
# - SWSCALE
|
2023-10-07 10:20:24 -06:00
|
|
|
# the following target will be defined
|
|
|
|
# FFmpeg::SDL::<component> - link to this target to
|
2023-10-07 03:01:35 -06:00
|
|
|
# the following variables will be defined
|
2023-10-07 10:20:24 -06:00
|
|
|
# FFmpeg_<component>_FOUND - System has <component>
|
|
|
|
# FFmpeg_<component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
|
|
|
|
# FFmpeg_<component>_LIBRARIES - Link these to use <component>
|
|
|
|
# FFmpeg_<component>_DEFINITIONS - Compiler switches required for using <component>
|
|
|
|
# FFmpeg_<component>_VERSION - The components version
|
2023-10-07 03:01:35 -06:00
|
|
|
#
|
|
|
|
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
|
|
|
|
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
|
|
|
|
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
|
2023-10-07 10:20:24 -06:00
|
|
|
# Copyright (c) 2023, Sam lantinga, <slouken@libsdl.org>
|
2023-10-07 03:01:35 -06:00
|
|
|
#
|
|
|
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
|
|
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
2023-10-07 10:20:24 -06:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/PkgConfigHelper.cmake")
|
2023-10-07 03:01:35 -06:00
|
|
|
|
|
|
|
# The default components were taken from a survey over other FindFFMPEG.cmake files
|
2023-10-07 10:20:24 -06:00
|
|
|
if(NOT FFmpeg_FIND_COMPONENTS)
|
2023-10-07 03:01:35 -06:00
|
|
|
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
|
2023-10-07 10:20:24 -06:00
|
|
|
foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS)
|
|
|
|
set(FFmpeg_FIND_REQUIRED_${_component} TRUE)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
find_package(PkgConfig QUIET)
|
2023-10-07 03:01:35 -06:00
|
|
|
|
|
|
|
#
|
|
|
|
### Macro: find_component
|
|
|
|
#
|
|
|
|
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
|
|
|
|
# include directories.
|
|
|
|
#
|
|
|
|
macro(find_component _component _pkgconfig _library _header)
|
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
# use pkg-config to get the directories and then use these values
|
|
|
|
# in the FIND_PATH() and FIND_LIBRARY() calls
|
|
|
|
if(PKG_CONFIG_FOUND)
|
|
|
|
pkg_check_modules(PC_${_component} QUIET ${_pkgconfig})
|
|
|
|
endif()
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
find_path(FFmpeg_${_component}_INCLUDE_DIRS
|
|
|
|
NAMES ${_header}
|
2023-10-07 03:01:35 -06:00
|
|
|
HINTS
|
|
|
|
${PC_${_component}_INCLUDE_DIRS}
|
|
|
|
PATH_SUFFIXES
|
|
|
|
ffmpeg
|
|
|
|
)
|
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
find_library(FFmpeg_${_component}_LIBRARY
|
|
|
|
NAMES ${_library}
|
|
|
|
HINTS
|
2023-10-07 03:01:35 -06:00
|
|
|
${PC_${_component}_LIBRARY_DIRS}
|
|
|
|
)
|
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
if(FFmpeg_${_component}_INCLUDE_DIRS AND FFmpeg_${_component}_LIBRARY)
|
|
|
|
set(FFmpeg_${_component}_FOUND TRUE)
|
|
|
|
endif()
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
if(PC_${_component}_FOUND)
|
|
|
|
get_flags_from_pkg_config("${FFmpeg_${_component}_LIBRARY}" "PC_${_component}" "${_component}")
|
|
|
|
endif()
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
set(FFmpeg_${_component}_VERSION "${PC_${_component}_VERSION}")
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
set(FFmpeg_${_component}_COMPILE_OPTIONS "${${_component}_options}" CACHE STRING "Extra compile options of FFmpeg ${_component}")
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
set(FFmpeg_${_component}_LIBRARIES "${${_component}_link_libraries}" CACHE STRING "Extra link libraries of FFmpeg ${_component}")
|
2023-10-07 03:01:35 -06:00
|
|
|
|
2023-10-07 10:20:24 -06:00
|
|
|
set(FFmpeg_${_component}_LINK_OPTIONS "${${_component}_link_options}" CACHE STRING "Extra link flags of FFmpeg ${_component}")
|
|
|
|
|
|
|
|
set(FFmpeg_${_component}_LINK_DIRECTORIES "${${_component}_link_directories}" CACHE PATH "Extra link directories of FFmpeg ${_component}")
|
|
|
|
|
|
|
|
mark_as_advanced(
|
|
|
|
FFmpeg_${_component}_INCLUDE_DIRS
|
|
|
|
FFmpeg_${_component}_LIBRARY
|
|
|
|
FFmpeg_${_component}_COMPILE_OPTIONS
|
|
|
|
FFmpeg_${_component}_LIBRARIES
|
|
|
|
FFmpeg_${_component}_LINK_OPTIONS
|
|
|
|
FFmpeg_${_component}_LINK_DIRECTORIES
|
|
|
|
)
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Check for all possible component.
|
|
|
|
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
|
|
|
|
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
|
|
|
|
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
|
|
|
|
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
|
|
|
|
find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
|
|
|
|
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
|
|
|
|
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
|
|
|
|
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
|
2023-10-07 03:01:35 -06:00
|
|
|
|
|
|
|
# Compile the list of required vars
|
2023-10-07 10:20:24 -06:00
|
|
|
set(_FFmpeg_REQUIRED_VARS)
|
|
|
|
foreach(_component ${FFmpeg_FIND_COMPONENTS})
|
|
|
|
list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_${_component}_INCLUDE_DIRS FFmpeg_${_component}_LIBRARY)
|
2023-10-07 03:01:35 -06:00
|
|
|
endforeach ()
|
|
|
|
|
|
|
|
# Give a nice error message if some of the required vars are missing.
|
|
|
|
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
|
2023-10-07 10:20:24 -06:00
|
|
|
|
|
|
|
set(FFMPEG_LIBRARIES)
|
|
|
|
if(FFmpeg_FOUND)
|
|
|
|
foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS)
|
|
|
|
if(FFmpeg_${_component}_FOUND)
|
|
|
|
list(APPEND FFMPEG_LIBRARIES FFmpeg::SDL::${_component})
|
|
|
|
if(NOT TARGET FFmpeg::SDL::${_component})
|
|
|
|
add_library(FFmpeg::SDL::${_component} UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(FFmpeg::SDL::${_component} PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${FFmpeg_${_component}_LIBRARY}"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${FFmpeg_${_component}_INCLUDE_DIRS}"
|
|
|
|
INTERFACE_COMPILE_OPTIONS "${FFmpeg_${_component}_COMPILE_OPTIONS}"
|
|
|
|
INTERFACE_LINK_LIBRARIES "${FFmpeg_${_component}_LIBRARIES}"
|
|
|
|
INTERFACE_LINK_OPTIONS "${FFmpeg_${_component}_LINK_OPTIONS}"
|
|
|
|
INTERFACE_LINK_DIRECTORIES "${FFmpeg_${_component}_LINK_DIRECTORIES}"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|