summaryrefslogtreecommitdiff
path: root/externals
diff options
context:
space:
mode:
Diffstat (limited to 'externals')
-rw-r--r--externals/find-modules/FindFFmpeg.cmake100
1 files changed, 100 insertions, 0 deletions
diff --git a/externals/find-modules/FindFFmpeg.cmake b/externals/find-modules/FindFFmpeg.cmake
new file mode 100644
index 000000000..77b331e00
--- /dev/null
+++ b/externals/find-modules/FindFFmpeg.cmake
@@ -0,0 +1,100 @@
1# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil)
2# Once done this will define
3#
4# FFMPEG_FOUND - system has ffmpeg or libav
5# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
6# FFMPEG_LIBRARIES - Link these to use ffmpeg
7# FFMPEG_LIBAVCODEC
8# FFMPEG_LIBAVFORMAT
9# FFMPEG_LIBAVUTIL
10#
11# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
12# Modified for other libraries by Lasse Kärkkäinen <tronic>
13# Modified for Hedgewars by Stepik777
14# Modified for FFmpeg-example Tuukka Pasanen 2018
15# Modified for yuzu toastUnlimted 2020
16#
17# Redistribution and use is allowed according to the terms of the New
18# BSD license.
19#
20
21include(FindPackageHandleStandardArgs)
22
23find_package_handle_standard_args(FFMPEG
24 FOUND_VAR FFMPEG_FOUND
25 REQUIRED_VARS
26 FFMPEG_LIBRARY
27 FFMPEG_INCLUDE_DIR
28 VERSION_VAR FFMPEG_VERSION
29)
30
31if(FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
32 # in cache already
33 set(FFMPEG_FOUND TRUE)
34else()
35 # use pkg-config to get the directories and then use these values
36 # in the FIND_PATH() and FIND_LIBRARY() calls
37 find_package(PkgConfig)
38 if(PKG_CONFIG_FOUND)
39 pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
40 pkg_check_modules(_FFMPEG_AVUTIL libavutil)
41 pkg_check_modules(_FFMPEG_SWSCALE libswscale)
42 endif()
43
44 find_path(FFMPEG_AVCODEC_INCLUDE_DIR
45 NAMES libavcodec/avcodec.h
46 PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}
47 /usr/include
48 /usr/local/include
49 /opt/local/include
50 /sw/include
51 PATH_SUFFIXES ffmpeg libav)
52
53 find_library(FFMPEG_LIBAVCODEC
54 NAMES avcodec
55 PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}
56 /usr/lib
57 /usr/local/lib
58 /opt/local/lib
59 /sw/lib)
60
61 find_library(FFMPEG_LIBAVUTIL
62 NAMES avutil
63 PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}
64 /usr/lib
65 /usr/local/lib
66 /opt/local/lib
67 /sw/lib)
68
69 find_library(FFMPEG_LIBSWSCALE
70 NAMES swscale
71 PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS}
72 /usr/lib
73 /usr/local/lib
74 /opt/local/lib
75 /sw/lib)
76
77 if(FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVUTIL AND FFMPEG_LIBSWSCALE)
78 set(FFMPEG_FOUND TRUE)
79 endif()
80
81 if(FFMPEG_FOUND)
82 set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})
83 set(FFMPEG_LIBRARIES
84 ${FFMPEG_LIBAVCODEC}
85 ${FFMPEG_LIBAVUTIL}
86 ${FFMPEG_LIBSWSCALE})
87 endif()
88
89 if(FFMPEG_FOUND)
90 if(NOT FFMPEG_FIND_QUIETLY)
91 message(STATUS
92 "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
93 endif()
94 else()
95 if(FFMPEG_FIND_REQUIRED)
96 message(FATAL_ERROR
97 "Could not find libavcodec or libavutil or libswscale")
98 endif()
99 endif()
100endif()