Warning, /multimedia/k3b/cmake/modules/FindFFmpeg.cmake is written in an unsupported language. File is not indexed.
0001 # vim: ts=2 sw=2 0002 # - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) 0003 # 0004 # Once done this will define 0005 # FFMPEG_FOUND - System has the all required components. 0006 # FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers. 0007 # FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. 0008 # FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components. 0009 # 0010 # For each of the components it will additionally set. 0011 # - AVCODEC 0012 # - AVDEVICE 0013 # - AVFORMAT 0014 # - AVUTIL 0015 # - POSTPROCESS 0016 # - SWSCALE 0017 # the following variables will be defined 0018 # <component>_FOUND - System has <component> 0019 # <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers 0020 # <component>_LIBRARIES - Link these to use <component> 0021 # <component>_DEFINITIONS - Compiler switches required for using <component> 0022 # <component>_VERSION - The components version 0023 # 0024 # SPDX-FileCopyrightText: 2006 Matthias Kretz <kretz@kde.org> 0025 # SPDX-FileCopyrightText: 2008 Alexander Neundorf <neundorf@kde.org> 0026 # SPDX-FileCopyrightText: 2011 Michael Jansen <kde@michael-jansen.biz> 0027 # SPDX-License-Identifier: BSD-3-Clause 0028 0029 include(FindPackageHandleStandardArgs) 0030 0031 # The default components were taken from a survey over other FindFFMPEG.cmake files 0032 if (NOT FFmpeg_FIND_COMPONENTS) 0033 set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) 0034 endif () 0035 0036 # 0037 ### Macro: set_component_found 0038 # 0039 # Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present. 0040 # 0041 macro(set_component_found _component ) 0042 if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS) 0043 # message(STATUS " - ${_component} found.") 0044 set(${_component}_FOUND TRUE) 0045 else () 0046 # message(STATUS " - ${_component} not found.") 0047 endif () 0048 endmacro() 0049 0050 # 0051 ### Macro: find_component 0052 # 0053 # Checks for the given component by invoking pkgconfig and then looking up the libraries and 0054 # include directories. 0055 # 0056 macro(find_component _component _pkgconfig _library _header) 0057 0058 if (NOT WIN32) 0059 # use pkg-config to get the directories and then use these values 0060 # in the FIND_PATH() and FIND_LIBRARY() calls 0061 find_package(PkgConfig) 0062 if (PKG_CONFIG_FOUND) 0063 pkg_check_modules(PC_${_component} ${_pkgconfig}) 0064 endif () 0065 endif (NOT WIN32) 0066 0067 find_path(${_component}_INCLUDE_DIRS ${_header} 0068 HINTS 0069 ${PC_LIB${_component}_INCLUDEDIR} 0070 ${PC_LIB${_component}_INCLUDE_DIRS} 0071 PATH_SUFFIXES 0072 ffmpeg 0073 ) 0074 0075 find_library(${_component}_LIBRARIES NAMES ${_library} 0076 HINTS 0077 ${PC_LIB${_component}_LIBDIR} 0078 ${PC_LIB${_component}_LIBRARY_DIRS} 0079 ) 0080 0081 set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.") 0082 set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.") 0083 0084 set_component_found(${_component}) 0085 0086 mark_as_advanced( 0087 ${_component}_INCLUDE_DIRS 0088 ${_component}_LIBRARIES 0089 ${_component}_DEFINITIONS 0090 ${_component}_VERSION) 0091 0092 endmacro() 0093 0094 0095 # Check for cached results. If there are skip the costly part. 0096 if (NOT FFMPEG_LIBRARIES) 0097 0098 # Check for all possible component. 0099 find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) 0100 find_component(AVFORMAT libavformat avformat libavformat/avformat.h) 0101 find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) 0102 find_component(AVUTIL libavutil avutil libavutil/avutil.h) 0103 find_component(SWSCALE libswscale swscale libswscale/swscale.h) 0104 find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) 0105 0106 # Check if the required components were found and add their stuff to the FFMPEG_* vars. 0107 foreach (_component ${FFmpeg_FIND_COMPONENTS}) 0108 if (${_component}_FOUND) 0109 # message(STATUS "Required component ${_component} present.") 0110 set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) 0111 set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) 0112 list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) 0113 else () 0114 # message(STATUS "Required component ${_component} missing.") 0115 endif () 0116 endforeach () 0117 0118 # Build the include path with duplicates removed. 0119 if (FFMPEG_INCLUDE_DIRS) 0120 list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) 0121 endif () 0122 0123 # cache the vars. 0124 set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) 0125 set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) 0126 set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) 0127 0128 mark_as_advanced(FFMPEG_INCLUDE_DIRS 0129 FFMPEG_LIBRARIES 0130 FFMPEG_DEFINITIONS) 0131 0132 endif () 0133 0134 # Now set the noncached _FOUND vars for the components. 0135 foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE) 0136 set_component_found(${_component}) 0137 endforeach () 0138 0139 # Compile the list of required vars 0140 set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) 0141 foreach (_component ${FFmpeg_FIND_COMPONENTS}) 0142 list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS) 0143 endforeach () 0144 0145 # Give a nice error message if some of the required vars are missing. 0146 find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})