diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/cmake/FindFFmpeg.cmake | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/cmake/FindFFmpeg.cmake')
| -rw-r--r-- | contrib/SDL-3.2.8/cmake/FindFFmpeg.cmake | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/cmake/FindFFmpeg.cmake b/contrib/SDL-3.2.8/cmake/FindFFmpeg.cmake new file mode 100644 index 0000000..62950c0 --- /dev/null +++ b/contrib/SDL-3.2.8/cmake/FindFFmpeg.cmake | |||
| @@ -0,0 +1,138 @@ | |||
| 1 | # - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC) | ||
| 2 | # | ||
| 3 | # Once done this will define | ||
| 4 | # FFMPEG_FOUND - System has the all required components. | ||
| 5 | # FFMPEG_LIBRARIES - Link these to use the required ffmpeg components. | ||
| 6 | # | ||
| 7 | # For each of the components it will additionally set. | ||
| 8 | # - AVCODEC | ||
| 9 | # - AVDEVICE | ||
| 10 | # - AVFORMAT | ||
| 11 | # - AVFILTER | ||
| 12 | # - AVUTIL | ||
| 13 | # - POSTPROC | ||
| 14 | # - SWSCALE | ||
| 15 | # the following target will be defined | ||
| 16 | # FFmpeg::SDL::<component> - link to this target to | ||
| 17 | # the following variables will be defined | ||
| 18 | # FFmpeg_<component>_FOUND - System has <component> | ||
| 19 | # FFmpeg_<component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers | ||
| 20 | # FFmpeg_<component>_LIBRARIES - Link these to use <component> | ||
| 21 | # FFmpeg_<component>_DEFINITIONS - Compiler switches required for using <component> | ||
| 22 | # FFmpeg_<component>_VERSION - The components version | ||
| 23 | # | ||
| 24 | # Copyright (c) 2006, Matthias Kretz, <kretz@kde.org> | ||
| 25 | # Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org> | ||
| 26 | # Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz> | ||
| 27 | # Copyright (c) 2023, Sam lantinga, <slouken@libsdl.org> | ||
| 28 | # | ||
| 29 | # Redistribution and use is allowed according to the terms of the BSD license. | ||
| 30 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
| 31 | |||
| 32 | include(FindPackageHandleStandardArgs) | ||
| 33 | include("${CMAKE_CURRENT_LIST_DIR}/PkgConfigHelper.cmake") | ||
| 34 | |||
| 35 | # The default components were taken from a survey over other FindFFMPEG.cmake files | ||
| 36 | if(NOT FFmpeg_FIND_COMPONENTS) | ||
| 37 | set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL) | ||
| 38 | foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS) | ||
| 39 | set(FFmpeg_FIND_REQUIRED_${_component} TRUE) | ||
| 40 | endforeach() | ||
| 41 | endif() | ||
| 42 | |||
| 43 | find_package(PkgConfig QUIET) | ||
| 44 | |||
| 45 | # | ||
| 46 | ### Macro: find_component | ||
| 47 | # | ||
| 48 | # Checks for the given component by invoking pkgconfig and then looking up the libraries and | ||
| 49 | # include directories. | ||
| 50 | # | ||
| 51 | macro(find_component _component _pkgconfig _library _header) | ||
| 52 | |||
| 53 | # use pkg-config to get the directories and then use these values | ||
| 54 | # in the FIND_PATH() and FIND_LIBRARY() calls | ||
| 55 | if(PKG_CONFIG_FOUND) | ||
| 56 | pkg_check_modules(PC_${_component} QUIET ${_pkgconfig}) | ||
| 57 | endif() | ||
| 58 | |||
| 59 | find_path(FFmpeg_${_component}_INCLUDE_DIRS | ||
| 60 | NAMES ${_header} | ||
| 61 | HINTS | ||
| 62 | ${PC_${_component}_INCLUDE_DIRS} | ||
| 63 | PATH_SUFFIXES | ||
| 64 | ffmpeg | ||
| 65 | ) | ||
| 66 | |||
| 67 | find_library(FFmpeg_${_component}_LIBRARY | ||
| 68 | NAMES ${_library} | ||
| 69 | HINTS | ||
| 70 | ${PC_${_component}_LIBRARY_DIRS} | ||
| 71 | ) | ||
| 72 | |||
| 73 | if(FFmpeg_${_component}_INCLUDE_DIRS AND FFmpeg_${_component}_LIBRARY) | ||
| 74 | set(FFmpeg_${_component}_FOUND TRUE) | ||
| 75 | endif() | ||
| 76 | |||
| 77 | if(PC_${_component}_FOUND) | ||
| 78 | get_flags_from_pkg_config("${FFmpeg_${_component}_LIBRARY}" "PC_${_component}" "${_component}") | ||
| 79 | endif() | ||
| 80 | |||
| 81 | set(FFmpeg_${_component}_VERSION "${PC_${_component}_VERSION}") | ||
| 82 | |||
| 83 | set(FFmpeg_${_component}_COMPILE_OPTIONS "${${_component}_options}" CACHE STRING "Extra compile options of FFmpeg ${_component}") | ||
| 84 | |||
| 85 | set(FFmpeg_${_component}_LIBRARIES "${${_component}_link_libraries}" CACHE STRING "Extra link libraries of FFmpeg ${_component}") | ||
| 86 | |||
| 87 | set(FFmpeg_${_component}_LINK_OPTIONS "${${_component}_link_options}" CACHE STRING "Extra link flags of FFmpeg ${_component}") | ||
| 88 | |||
| 89 | set(FFmpeg_${_component}_LINK_DIRECTORIES "${${_component}_link_directories}" CACHE PATH "Extra link directories of FFmpeg ${_component}") | ||
| 90 | |||
| 91 | mark_as_advanced( | ||
| 92 | FFmpeg_${_component}_INCLUDE_DIRS | ||
| 93 | FFmpeg_${_component}_LIBRARY | ||
| 94 | FFmpeg_${_component}_COMPILE_OPTIONS | ||
| 95 | FFmpeg_${_component}_LIBRARIES | ||
| 96 | FFmpeg_${_component}_LINK_OPTIONS | ||
| 97 | FFmpeg_${_component}_LINK_DIRECTORIES | ||
| 98 | ) | ||
| 99 | endmacro() | ||
| 100 | |||
| 101 | # Check for all possible component. | ||
| 102 | find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h) | ||
| 103 | find_component(AVFORMAT libavformat avformat libavformat/avformat.h) | ||
| 104 | find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h) | ||
| 105 | find_component(AVUTIL libavutil avutil libavutil/avutil.h) | ||
| 106 | find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h) | ||
| 107 | find_component(SWSCALE libswscale swscale libswscale/swscale.h) | ||
| 108 | find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h) | ||
| 109 | find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h) | ||
| 110 | |||
| 111 | # Compile the list of required vars | ||
| 112 | set(_FFmpeg_REQUIRED_VARS) | ||
| 113 | foreach(_component ${FFmpeg_FIND_COMPONENTS}) | ||
| 114 | list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_${_component}_INCLUDE_DIRS FFmpeg_${_component}_LIBRARY) | ||
| 115 | endforeach () | ||
| 116 | |||
| 117 | # Give a nice error message if some of the required vars are missing. | ||
| 118 | find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS}) | ||
| 119 | |||
| 120 | set(FFMPEG_LIBRARIES) | ||
| 121 | if(FFmpeg_FOUND) | ||
| 122 | foreach(_component IN LISTS FFmpeg_FIND_COMPONENTS) | ||
| 123 | if(FFmpeg_${_component}_FOUND) | ||
| 124 | list(APPEND FFMPEG_LIBRARIES FFmpeg::SDL::${_component}) | ||
| 125 | if(NOT TARGET FFmpeg::SDL::${_component}) | ||
| 126 | add_library(FFmpeg::SDL::${_component} UNKNOWN IMPORTED) | ||
| 127 | set_target_properties(FFmpeg::SDL::${_component} PROPERTIES | ||
| 128 | IMPORTED_LOCATION "${FFmpeg_${_component}_LIBRARY}" | ||
| 129 | INTERFACE_INCLUDE_DIRECTORIES "${FFmpeg_${_component}_INCLUDE_DIRS}" | ||
| 130 | INTERFACE_COMPILE_OPTIONS "${FFmpeg_${_component}_COMPILE_OPTIONS}" | ||
| 131 | INTERFACE_LINK_LIBRARIES "${FFmpeg_${_component}_LIBRARIES}" | ||
| 132 | INTERFACE_LINK_OPTIONS "${FFmpeg_${_component}_LINK_OPTIONS}" | ||
| 133 | INTERFACE_LINK_DIRECTORIES "${FFmpeg_${_component}_LINK_DIRECTORIES}" | ||
| 134 | ) | ||
| 135 | endif() | ||
| 136 | endif() | ||
| 137 | endforeach() | ||
| 138 | endif() | ||
