blob: a0b4d2005c8616a35162e23cb0e51d5cb3b8fac1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
# Distributed under the OSI-approved BSD 3-Clause License.
#
#.rst:
# FindFFMPEG
# --------
#
# Find the FFPMEG libraries
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# The following variables will be defined:
#
# ``FFMPEG_FOUND``
# True if FFMPEG found on the local system
#
# ``FFMPEG_INCLUDE_DIRS``
# Location of FFMPEG header files
#
# ``FFMPEG_LIBRARY_DIRS``
# Location of FFMPEG libraries
#
# ``FFMPEG_LIBRARIES``
# List of the FFMPEG libraries found
#
#
include(FindPackageHandleStandardArgs)
include(SelectLibraryConfigurations)
include(CMakeFindDependencyMacro)
if(NOT FFMPEG_FOUND)
function(select_library_configurations_from_names)
cmake_parse_arguments(_slc "" "BASENAME" "NAMES;NAMES_RELEASE;NAMES_DEBUG" ${ARGN})
list(APPEND _slc_NAMES_RELEASE ${_slc_NAMES})
list(APPEND _slc_NAMES_DEBUG ${_slc_NAMES})
find_library(${_slc_BASENAME}_LIBRARY_RELEASE NAMES ${_slc_NAMES_RELEASE} PATHS ${_IMPORT_PREFIX}/lib/ NO_DEFAULT_PATH)
find_library(${_slc_BASENAME}_LIBRARY_DEBUG NAMES ${_slc_NAMES_DEBUG} PATHS ${_IMPORT_PREFIX}/debug/lib/ NO_DEFAULT_PATH)
select_library_configurations(${_slc_BASENAME})
set(${_slc_BASENAME}_LIBRARIES ${${_slc_BASENAME}_LIBRARIES} PARENT_SCOPE)
endfunction()
function(select_library_configurations_from_targets)
cmake_parse_arguments(_slc "" "BASENAME" "TARGETS" ${ARGN})
foreach(_target ${_slc_TARGETS})
get_target_property(_rel ${_target} IMPORTED_LOCATION_RELEASE)
get_target_property(_dbg ${_target} IMPORTED_LOCATION_DEBUG)
get_target_property(_deps ${_target} INTERFACE_LINK_LIBRARIES)
list(APPEND ${_slc_BASENAME}_LIBRARY_RELEASE ${_rel})
list(APPEND ${_slc_BASENAME}_LIBRARY_DEBUG ${_dbg})
foreach(_dep ${_deps})
if(TARGET ${_dep})
get_target_property(_dep_rel ${_dep} IMPORTED_LOCATION_RELEASE)
get_target_property(_dep_dbg ${_dep} IMPORTED_LOCATION_DEBUG)
list(APPEND ${_slc_BASENAME}_LIBRARY_RELEASE ${_dep_rel})
list(APPEND ${_slc_BASENAME}_LIBRARY_DEBUG ${_dep_dbg})
endif()
endforeach()
endforeach()
select_library_configurations(${_slc_BASENAME})
set(${_slc_BASENAME}_LIBRARIES ${${_slc_BASENAME}_LIBRARIES} PARENT_SCOPE)
endfunction()
set(FFMPEG_VERSION "4.3.1")
find_dependency(Threads)
if(UNIX)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS -pthread)
endif()
if(UNIX AND NOT APPLE)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS -lX11)
endif()
if(@ENABLE_BZIP2@)
find_dependency(BZip2)
select_library_configurations_from_targets(BASENAME BZip2 TARGETS BZip2::BZip2)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${BZip2_LIBRARIES})
endif()
if(@ENABLE_ICONV@)
find_dependency(Iconv)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${Iconv_LIBRARIES})
endif()
if(@ENABLE_FDKAAC@)
select_library_configurations_from_names(BASENAME FDK NAMES fdk-aac libfdk-aac)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${FDK_LIBRARIES})
endif()
if(@ENABLE_LZMA@)
find_dependency(LibLZMA)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${LibLZMA_LIBRARIES})
endif()
if(@ENABLE_LAME@)
find_dependency(mp3lame)
select_library_configurations_from_targets(BASENAME mp3lame TARGETS mp3lame::mp3lame)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${mp3lame_LIBRARIES})
endif()
if(@ENABLE_NVCODEC@)
if(UNIX)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS dl)
endif()
endif()
if(@ENABLE_OPENCL@)
find_dependency(OpenCL)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${OpenCL_LIBRARIES})
endif()
if(@ENABLE_OPENSSL@)
find_dependency(OpenSSL)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${OPENSSL_LIBRARIES})
endif()
if(@ENABLE_OPUS@)
find_dependency(Opus)
select_library_configurations_from_targets(BASENAME Opus TARGETS Opus::opus)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${Opus_LIBRARIES})
endif()
if(@ENABLE_SDL2@)
find_dependency(SDL2)
if(TARGET SDL2::SDL2-static)
select_library_configurations_from_targets(BASENAME SDL2 TARGETS SDL2::SDL2-static)
else()
select_library_configurations_from_targets(BASENAME SDL2 TARGETS SDL2::SDL2)
endif()
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${SDL2_LIBRARIES})
endif()
if(@ENABLE_SNAPPY@)
find_dependency(Snappy)
select_library_configurations_from_targets(BASENAME Snappy TARGETS Snappy::snappy)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${Snappy_LIBRARIES})
endif()
if(@ENABLE_SOXR@)
select_library_configurations_from_names(BASENAME SOXR NAMES soxr)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${SOXR_LIBRARIES})
endif()
if(@ENABLE_SPEEX@)
select_library_configurations_from_names(BASENAME SPEEX NAMES_RELEASE libspeex NAMES_DEBUG libspeexd)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${SPEEX_LIBRARIES})
endif()
if(@ENABLE_THEORA@)
find_dependency(Ogg) # ensure Ogg::ogg is defined as a target
find_dependency(unofficial-theora)
select_library_configurations_from_targets(BASENAME THEORA TARGETS unofficial::theora::theoraenc)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${THEORA_LIBRARIES})
endif()
if(@ENABLE_VORBIS@)
find_dependency(Vorbis)
select_library_configurations_from_targets(BASENAME vorbis TARGETS Vorbis::vorbis Vorbis::vorbisenc)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${vorbis_LIBRARIES})
endif()
if(@ENABLE_VPX@)
find_dependency(unofficial-libvpx)
select_library_configurations_from_targets(BASENAME libvpx TARGETS unofficial::libvpx::libvpx)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${libvpx_LIBRARIES})
endif()
if(@ENABLE_WAVPACK@)
find_dependency(wavpack)
select_library_configurations_from_targets(BASENAME wavpack TARGETS WavPack::wavpack)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${wavpack_LIBRARIES})
endif()
if(@ENABLE_X264@)
select_library_configurations_from_names(BASENAME X264 NAMES x264 libx264)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${X264_LIBRARIES})
if(UNIX)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS dl)
endif()
endif()
if(@ENABLE_X265@)
select_library_configurations_from_names(BASENAME X265 NAMES x265 x265-static)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${X265_LIBRARIES})
endif()
if(@ENABLE_ZLIB@)
find_dependency(ZLIB)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${ZLIB_LIBRARIES})
endif()
# Platform dependent libraries required by FFMPEG
if(WIN32)
if(NOT CYGWIN)
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS wsock32 ws2_32 secur32 bcrypt strmiids Vfw32 Shlwapi mfplat mfuuid)
endif()
else()
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS m)
endif()
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
set(_IMPORT_PREFIX)
macro(FFMPEG_FIND varname shortname headername)
if(NOT FFMPEG_${varname}_INCLUDE_DIRS)
find_path(FFMPEG_${varname}_INCLUDE_DIRS NAMES lib${shortname}/${headername} ${headername} PATHS ${_IMPORT_PREFIX}/include NO_DEFAULT_PATH)
endif()
if(NOT FFMPEG_${varname}_LIBRARY)
find_library(FFMPEG_${varname}_LIBRARY_RELEASE NAMES ${shortname} PATHS ${_IMPORT_PREFIX}/lib/ NO_DEFAULT_PATH)
find_library(FFMPEG_${varname}_LIBRARY_DEBUG NAMES ${shortname}d ${shortname} PATHS ${_IMPORT_PREFIX}/debug/lib/ NO_DEFAULT_PATH)
get_filename_component(FFMPEG_${varname}_LIBRARY_RELEASE_DIR ${FFMPEG_${varname}_LIBRARY_RELEASE} DIRECTORY)
get_filename_component(FFMPEG_${varname}_LIBRARY_DEBUG_DIR ${FFMPEG_${varname}_LIBRARY_DEBUG} DIRECTORY)
select_library_configurations(FFMPEG_${varname})
set(FFMPEG_${varname}_LIBRARY ${FFMPEG_${varname}_LIBRARY} CACHE STRING "")
endif()
if (FFMPEG_${varname}_LIBRARY AND FFMPEG_${varname}_INCLUDE_DIRS)
set(FFMPEG_${varname}_FOUND TRUE BOOL)
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_${varname}_INCLUDE_DIRS})
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_${varname}_LIBRARY})
list(APPEND FFMPEG_LIBRARY_DIRS ${FFMPEG_${varname}_LIBRARY_RELEASE_DIR} ${FFMPEG_${varname}_LIBRARY_DEBUG_DIR})
endif()
endmacro(FFMPEG_FIND)
if(APPLE)
find_library(VT_UNIT VideoToolbox)
if (NOT VT_UNIT)
message(FATAL_ERROR "VideoToolbox not found")
endif()
find_library(AT_UNIT AudioToolbox)
if (NOT AT_UNIT)
message(FATAL_ERROR "AudioToolbox not found")
endif()
find_library(SEC_UNIT Security)
if (NOT SEC_UNIT)
message(FATAL_ERROR "Security not found")
endif()
find_library(CF_UNIT CoreFoundation)
if (NOT CF_UNIT)
message(FATAL_ERROR "CoreFoundation not found")
endif()
find_library(CM_UNIT CoreMedia)
if (NOT CM_UNIT)
message(FATAL_ERROR "CoreMedia not found")
endif()
find_library(CV_UNIT CoreVideo)
if (NOT CV_UNIT)
message(FATAL_ERROR "CoreVideo not found")
endif()
list(APPEND FFMPEG_PLATFORM_DEPENDENT_LIBS ${VT_UNIT} ${AT_UNIT} ${SEC_UNIT} ${CF_UNIT} ${CM_UNIT} ${CV_UNIT})
endif()
if(@ENABLE_AVDEVICE@)
FFMPEG_FIND(libavdevice avdevice avdevice.h)
endif()
if(@ENABLE_AVFORMAT@)
FFMPEG_FIND(libavformat avformat avformat.h)
endif()
if(@ENABLE_AVCODEC@)
FFMPEG_FIND(libavcodec avcodec avcodec.h)
endif()
if(@ENABLE_AVFILTER@)
FFMPEG_FIND(libavfilter avfilter avfilter.h)
endif()
if(@ENABLE_AVRESAMPLE@)
FFMPEG_FIND(libavresample avresample avresample.h)
endif()
if(@ENABLE_POSTPROC@)
FFMPEG_FIND(libpostproc postproc postprocess.h)
endif()
if(@ENABLE_SWRESAMPLE@)
FFMPEG_FIND(libswresample swresample swresample.h)
endif()
if(@ENABLE_SWSCALE@)
FFMPEG_FIND(libswscale swscale swscale.h)
endif()
FFMPEG_FIND(libavutil avutil avutil.h)
if (FFMPEG_libavutil_FOUND)
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_LIBRARY_DIRS)
set(FFMPEG_libavutil_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
if(FFMPEG_libavcodec_FOUND)
set(FFMPEG_libavcodec_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavdevice_FOUND)
set(FFMPEG_libavdevice_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavfilter_FOUND)
set(FFMPEG_libavfilter_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavformat_FOUND)
set(FFMPEG_libavformat_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libavresample_FOUND)
set(FFMPEG_libavresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libswresample_FOUND)
set(FFMPEG_libswresample_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
if(FFMPEG_libswscale_FOUND)
set(FFMPEG_libswscale_VERSION "${FFMPEG_VERSION}" CACHE STRING "")
endif()
list(APPEND FFMPEG_LIBRARIES
${FFMPEG_PLATFORM_DEPENDENT_LIBS}
)
set(FFMPEG_LIBRARY ${FFMPEG_LIBRARIES})
set(FFMPEG_FOUND TRUE CACHE BOOL "")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "")
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "")
set(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBRARY_DIRS} CACHE STRING "")
endif()
find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_LIBRARY_DIRS FFMPEG_INCLUDE_DIRS)
endif()
|