Warning, /graphics/digikam/core/cmake/modules/FindFFmpeg.cmake is written in an unsupported language. File is not indexed.
0001 # 0002 # CMake script to find FFMPEG libraries 0003 # Once done this will define: 0004 # 0005 # FFMPEG_FOUND - system has ffmpeg 0006 # FFMPEG_INCLUDE_DIR - Include directory necessary for using the ffmpeg headers 0007 # FFMPEG_LIBRARIES - Link these to use ffmpeg 0008 # FFMPEG_DEFINITIONS - Compiler switches required for using ffmpeg 0009 # 0010 # For each of the components it will additionally set. 0011 # 0012 # - AVCODEC 0013 # - AVDEVICE 0014 # - AVFORMAT 0015 # - AVUTIL 0016 # - POSTPROCESS 0017 # - SWSCALE 0018 # - AVRESAMPLE 0019 # - SWRESAMPLE 0020 # 0021 # NOTE: default components are AVFORMAT, AVUTIL, AVCODEC. 0022 # 0023 # The following variables will be defined 0024 # 0025 # <component>_FOUND - System has <component> 0026 # <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers 0027 # <component>_LIBRARIES - Link these to use <component> 0028 # <component>_DEFINITIONS - Compiler switches required for using <component> 0029 # <component>_VERSION - The components version 0030 # 0031 # SPDX-FileCopyrightText: 2006, by Matthias Kretz, <kretz at kde dot org> 0032 # SPDX-FileCopyrightText: 2008, by Alexander Neundorf, <neundorf at kde dot org> 0033 # SPDX-FileCopyrightText: 2011 by Michael Jansen, <kde at michael-jansen dot biz> 0034 # SPDX-FileCopyrightText: 2016-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com> 0035 # 0036 # SPDX-License-Identifier: BSD-3-Clause 0037 # 0038 0039 INCLUDE(FindPackageHandleStandardArgs) 0040 0041 # The default components were taken from a survey over other FindFFMPEG.cmake files 0042 0043 IF(NOT FFmpeg_FIND_COMPONENTS) 0044 0045 SET(FFmpeg_FIND_COMPONENTS AVCODEC AVFILTER AVFORMAT AVUTIL SWSCALE) 0046 0047 ENDIF() 0048 0049 # Macro to marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present. 0050 # 0051 MACRO(set_component_found _component) 0052 0053 IF(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS) 0054 0055 # message(STATUS " - ${_component} found.") 0056 0057 SET(${_component}_FOUND TRUE) 0058 0059 ELSE() 0060 0061 # message(STATUS " - ${_component} not found.") 0062 0063 SET(${_component}_FOUND FALSE) 0064 0065 ENDIF() 0066 0067 ENDMACRO() 0068 0069 # Macro to checks for the given component by invoking pkgconfig and then looking up the libraries and 0070 # include directories. 0071 0072 MACRO(find_component _component _pkgconfig _library _header) 0073 0074 # use pkg-config to get the directories and then use these values 0075 # in the FIND_PATH() and FIND_LIBRARY() calls 0076 0077 FIND_PACKAGE(PkgConfig) 0078 0079 IF(PKG_CONFIG_FOUND) 0080 0081 MESSAGE(STATUS "Use PkgConfig to check FFMPEG ${_component} availability...") 0082 pkg_check_modules(PC_${_component} ${_pkgconfig}) 0083 0084 ELSE() 0085 0086 MESSAGE(WARNING "PkgConfig not found!") 0087 0088 ENDIF() 0089 0090 FIND_PATH(${_component}_INCLUDE_DIRS ${_header} 0091 HINTS 0092 ${PC_${_component}_INCLUDEDIR} 0093 ${PC_${_component}_INCLUDE_DIRS} 0094 PATH_SUFFIXES 0095 ffmpeg 0096 ) 0097 0098 FIND_LIBRARY(${_component}_LIBRARIES NAMES ${_library} 0099 HINTS 0100 ${PC_${_component}_LIBDIR} 0101 ${PC_${_component}_LIBRARY_DIRS} 0102 ) 0103 0104 SET(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} 0105 CACHE STRING "The ${_component} CFLAGS.") 0106 0107 SET(${_component}_VERSION ${PC_${_component}_VERSION} 0108 CACHE STRING "The ${_component} version number.") 0109 0110 set_component_found(${_component}) 0111 0112 MARK_AS_ADVANCED( 0113 ${_component}_INCLUDE_DIRS 0114 ${_component}_LIBRARIES 0115 ${_component}_DEFINITIONS 0116 ${_component}_VERSION 0117 ) 0118 0119 ENDMACRO() 0120 0121 # Check for cached results. If there are skip the costly part. 0122 0123 if(NOT FFMPEG_LIBRARIES) 0124 0125 # Check for all possible component. 0126 0127 find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) 0128 find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h) 0129 find_component(AVFORMAT libavformat avformat libavformat/avformat.h) 0130 find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) 0131 find_component(AVUTIL libavutil avutil libavutil/avutil.h) 0132 find_component(SWSCALE libswscale swscale libswscale/swscale.h) 0133 find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) 0134 find_component(AVRESAMPLE libavresample avresample libavresample/avresample.h) 0135 find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) 0136 0137 # Check if the required components were found and add their stuff to the FFMPEG_* vars. 0138 0139 FOREACH(_component ${FFmpeg_FIND_COMPONENTS}) 0140 0141 IF(${_component}_FOUND) 0142 0143 # message(STATUS "Required component ${_component} present.") 0144 0145 SET(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES}) 0146 SET(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS}) 0147 LIST(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS}) 0148 0149 ELSE() 0150 0151 # message(STATUS "Required component ${_component} missing.") 0152 0153 ENDIF() 0154 0155 ENDFOREACH() 0156 0157 # Build the include path with duplicates removed. 0158 0159 IF(FFMPEG_INCLUDE_DIRS) 0160 0161 LIST(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) 0162 0163 ENDIF() 0164 0165 # cache the vars. 0166 0167 SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE) 0168 SET(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE) 0169 SET(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE) 0170 0171 MARK_AS_ADVANCED(FFMPEG_INCLUDE_DIRS 0172 FFMPEG_LIBRARIES 0173 FFMPEG_DEFINITIONS 0174 ) 0175 0176 ENDIF() 0177 0178 # Now set the non-cached _FOUND vars for the components. 0179 0180 FOREACH(_component AVCODEC AVDEVICE AVFILTER AVFORMAT AVUTIL POSTPROCESS SWSCALE AVRESAMPLE SWRESAMPLE) 0181 0182 set_component_found(${_component}) 0183 0184 ENDFOREACH() 0185 0186 # Compile the list of required vars 0187 SET(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS) 0188 0189 FOREACH(_component ${FFmpeg_FIND_COMPONENTS}) 0190 0191 LIST(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS) 0192 0193 ENDFOREACH() 0194 0195 # Give a nice error message if some of the required vars are missing. 0196 FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS}) 0197 0198 MESSAGE(STATUS "FFMPEG_FOUND = ${FFMPEG_FOUND}") 0199 MESSAGE(STATUS "FFMPEG_INCLUDE_DIRS = ${FFMPEG_INCLUDE_DIRS}") 0200 MESSAGE(STATUS "FFMPEG_LIBRARIES = ${FFMPEG_LIBRARIES}") 0201 MESSAGE(STATUS "FFMPEG_DEFINITIONS = ${FFMPEG_DEFINITIONS}")