forked from mpv-player/mpv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
565 lines (501 loc) · 13.2 KB
/
CMakeLists.txt
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
cmake_minimum_required(VERSION 3.0)
option(MPV_BUILD_SIMULATOR "Build PC simulator to ease debugging" FALSE)
set(MPV_FFMPEG_LIBS_DIR "" CACHE STRING "Specfiy FFMPEG static library directory")
set(mpv_vita_title_id "MPV000001")
set(mpv_vita_name "mpv-vita")
set(mpv_vita_version "01.00")
# apply vitasdk toolchain setup
if(NOT MPV_BUILD_SIMULATOR)
if(NOT DEFINED ENV{VITASDK})
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
set(CMAKE_TOOLCHAIN_FILE
"$ENV{VITASDK}/share/vita.toolchain.cmake"
CACHE PATH "toolchain file")
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
endif()
set(CMAKE_C_STANDARD 11)
set(mpv_src_files)
set(mpv_gen_files)
set(mpv_gen_dir)
set(mpv_inc_dirs)
set(mpv_link_libs)
set(mpv_compile_defs)
set(mpv_compile_flags)
list(APPEND mpv_inc_dirs
${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND mpv_gen_dir
${CMAKE_CURRENT_BINARY_DIR}/generated_files)
include(FindPkgConfig)
function(_generate_source _out_var _abs_out_path _abs_script_path)
# accumulate file paths from script arguments
set(_dep_file_paths)
list(APPEND _dep_file_paths ${_abs_script_path})
foreach(_arg IN LISTS ARGN)
set(_abs_arg_path ${_cwd}/${_arg})
if(EXISTS ${_abs_arg_path})
list(APPEND _dep_file_paths ${_abs_arg_path})
endif()
endforeach()
get_filename_component(_abs_out_dir ${_abs_out_path} DIRECTORY)
add_custom_command(OUTPUT ${_abs_out_path}
DEPENDS ${_dep_file_paths}
COMMAND ${CMAKE_COMMAND} -E make_directory ${_abs_out_dir}
COMMAND ${_abs_script_path} ${ARGN} ${_abs_out_path})
list(APPEND _out_result ${${_out_var}} ${_abs_out_path})
set(${_out_var} ${_out_result} PARENT_SCOPE)
endfunction()
function(_add_pkg_deps _out_inc_dirs _out_link_libs)
set(_lib_type)
if(BUILD_VITA)
set(_lib_type _STATIC)
endif()
set(_inc_result ${${_out_inc_dirs}})
set(_libs_result ${${_out_link_libs}})
foreach(_arg IN LISTS ARGN)
list(APPEND _inc_result ${${_arg}${_lib_type}_INCLUDE_DIRS}})
list(APPEND _libs_result ${${_arg}${_lib_type}_LIBRARIES})
endforeach()
set(${_out_inc_dirs} ${_inc_result} PARENT_SCOPE)
set(${_out_link_libs} ${_libs_result} PARENT_SCOPE)
endfunction()
project(mpv-vita)
list(APPEND mpv_src_files
# audio
audio/out/internal.h
audio/aframe.h
audio/aframe.c
audio/chmap.h
audio/chmap.c
audio/chmap_sel.h
audio/chmap_sel.c
audio/fmt-conversion.h
audio/fmt-conversion.c
audio/format.h
audio/format.c
audio/decode/ad_lavc.c
audio/filter/af_drop.c
audio/filter/af_scaletempo2.c
audio/filter/af_scaletempo2_internals.h
audio/filter/af_scaletempo2_internals.c
audio/out/ao.h
audio/out/ao.c
audio/out/ao_null.c
audio/out/buffer.c
# core
common/encode.h
common/global.h
common/msg_control.h
common/av_common.h
common/av_common.c
common/av_log.h
common/av_log.c
common/codecs.h
common/codecs.c
common/common.h
common/common.c
common/encode_lavc.h
common/encode_lavc.c
common/msg.h
common/msg.c
common/playlist.h
common/playlist.c
common/recorder.h
common/recorder.c
common/stats.h
common/stats.c
common/tags.h
common/tags.c
common/version.c
# demuxers
demux/matroska.h
demux/stheader.h
demux/cue.h
demux/cue.c
demux/cache.h
demux/cache.c
demux/codec_tags.h
demux/codec_tags.c
demux/demux.h
demux/demux.c
demux/demux_cue.c
demux/demux_disc.c
demux/demux_edl.c
demux/demux_lavf.c
demux/demux_mf.c
demux/demux_mkv.c
demux/demux_mkv_timeline.c
demux/demux_null.c
demux/demux_playlist.c
demux/demux_raw.c
demux/demux_timeline.c
demux/ebml.h
demux/ebml.c
demux/packet.h
demux/packet.c
demux/timeline.h
demux/timeline.c
# filters
filters/filter_internal.h
filters/f_async_queue.h
filters/f_async_queue.c
filters/f_autoconvert.h
filters/f_autoconvert.c
filters/f_auto_filters.h
filters/f_auto_filters.c
filters/f_decoder_wrapper.h
filters/f_decoder_wrapper.c
filters/f_demux_in.h
filters/f_demux_in.c
filters/f_output_chain.h
filters/f_output_chain.c
filters/f_swresample.h
filters/f_swresample.c
filters/f_swscale.h
filters/f_swscale.c
filters/f_utils.h
filters/f_utils.c
filters/filter.h
filters/filter.c
filters/frame.h
filters/frame.c
filters/user_filters.h
filters/user_filters.c
# input
input/cmd.h
input/cmd.c
input/event.h
input/event.c
input/input.h
input/input.c
input/keycodes.h
input/keycodes.c
# misc
misc/ctype.h
misc/linked_list.h
misc/bstr.h
misc/bstr.c
misc/charset_conv.h
misc/charset_conv.c
misc/dispatch.h
misc/dispatch.c
misc/json.h
misc/json.c
misc/natural_sort.h
misc/natural_sort.c
misc/node.h
misc/node.c
misc/rendezvous.h
misc/rendezvous.c
misc/thread_pool.h
misc/thread_pool.c
misc/thread_tools.h
misc/thread_tools.c
# options
options/m_config.h
options/m_config_core.h
options/m_config_core.c
options/m_config_frontend.h
options/m_config_frontend.c
options/m_option.h
options/m_option.c
options/m_property.h
options/m_property.c
options/options.h
options/options.c
options/parse_commandline.h
options/parse_commandline.c
options/parse_configfile.h
options/parse_configfile.c
options/path.h
options/path.c
# player
player/core.h
player/audio.c
player/client.h
player/client.c
player/command.h
player/command.c
player/configfiles.c
player/external_files.h
player/external_files.c
player/loadfile.c
player/main.c
player/misc.c
player/osd.c
player/playloop.c
player/screenshot.h
player/screenshot.c
player/scripting.c
player/sub.c
player/video.c
# streams
stream/cookies.h
stream/cookies.c
stream/stream.h
stream/stream.c
stream/stream_avdevice.c
stream/stream_cb.c
stream/stream_concat.c
stream/stream_edl.c
stream/stream_file.c
stream/stream_lavf.c
stream/stream_memory.c
stream/stream_mf.c
stream/stream_null.c
stream/stream_slice.c
# subtitles
sub/sd.h
sub/osd_state.h
sub/ass_mp.h
sub/ass_mp.c
sub/dec_sub.h
sub/dec_sub.c
sub/draw_bmp.h
sub/draw_bmp.c
sub/filter_sdh.c
sub/img_convert.h
sub/img_convert.c
sub/lavc_conv.c
sub/osd.h
sub/osd.c
sub/sd_ass.c
sub/sd_lavc.c
# video
video/csputils.h
video/csputils.c
video/fmt-conversion.h
video/fmt-conversion.c
video/hwdec.h
video/hwdec.c
video/image_loader.h
video/image_loader.c
video/image_writer.h
video/image_writer.c
video/img_format.h
video/img_format.c
video/mp_image.h
video/mp_image.c
video/mp_image_pool.h
video/mp_image_pool.c
video/repack.h
video/repack.c
video/sws_utils.h
video/sws_utils.c
video/decode/vd_lavc.c
video/out/aspect.h
video/out/aspect.c
video/out/bitmap_packer.h
video/out/bitmap_packer.c
video/out/dither.h
video/out/dither.c
video/out/dr_helper.h
video/out/dr_helper.c
video/out/filter_kernels.h
video/out/filter_kernels.c
video/out/vo.h
video/out/vo.c
video/out/vo_null.c
video/out/win_state.h
video/out/win_state.c
# os dependent
osdep/atomic.h
osdep/compiler.h
osdep/endian.h
osdep/getpid.h
osdep/main-fn.h
osdep/path.h
osdep/strnlen.h
osdep/terminal.h
osdep/io.h
osdep/io.c
osdep/subprocess.h
osdep/subprocess.c
osdep/threads.h
osdep/threads.c
osdep/timer.h
osdep/timer.c
# tree allocator
ta/ta.h
ta/ta.c
ta/ta_talloc.h
ta/ta_talloc.c
ta/ta_utils.c
# vita implementation
sub/osd_dummy.c
input/ipc-dummy.c
osdep/timer-linux.c
osdep/terminal-dummy.c
osdep/subprocess-dummy.c
audio/out/ao_vita.c
video/out/vo_vita.c
osdep/path-vita.c
osdep/main-fn-vita.c
osdep/vita/ui_context.h
osdep/vita/ui_device.h
osdep/vita/ui_driver.h
osdep/vita/ui_panel.h
osdep/vita/ui_panel_player.c
osdep/vita/ui_panel_files.c
osdep/vita/player_osc.h
osdep/vita/player_osc.c
osdep/vita/player_perf.h
osdep/vita/player_perf.c
osdep/vita/shape_draw.h
osdep/vita/shape_draw.c
osdep/vita/key_helper.h
osdep/vita/key_helper.c
)
set(_simulator_flag 0)
if(MPV_BUILD_SIMULATOR)
set(_simulator_flag 1)
endif()
# config file content
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.h "\
#define CONFIGURATION \"vita\"
#define HAVE_GPL 1
#define HAVE_VITA 1
#define HAVE_ZLIB 1
#define HAVE_STDATOMIC 1
#define HAVE_TA_LEAK_REPORT ${_simulator_flag}
#define MPV_VITA_TITLE_ID \"${mpv_vita_title_id}\"
")
# generate file
set(_mpv_icons)
list(APPEND _mpv_icons
arrow_downward.png
file_audio.png
file_video.png
file_default.png
folder_default.png
battery_frame.png
)
foreach(_icon ${_mpv_icons})
_generate_source(mpv_gen_files
${mpv_gen_dir}/generated/etc/vita/icons/${_icon}.inc
${CMAKE_CURRENT_SOURCE_DIR}/TOOLS/file2string.py
${CMAKE_CURRENT_SOURCE_DIR}/etc/vita/icons/${_icon})
endforeach()
_generate_source(mpv_gen_files ${mpv_gen_dir}/generated/version.h
${CMAKE_CURRENT_SOURCE_DIR}/version.py)
_generate_source(mpv_gen_files ${mpv_gen_dir}/generated/ebml_defs.inc
${CMAKE_CURRENT_SOURCE_DIR}/TOOLS/matroska.py
--generate-definitions)
_generate_source(mpv_gen_files ${mpv_gen_dir}/generated/ebml_types.h
${CMAKE_CURRENT_SOURCE_DIR}/TOOLS/matroska.py
--generate-header)
_generate_source(mpv_gen_files ${mpv_gen_dir}/config.h
cmake -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/config.h)
# ffmpeg depedencies
if(EXISTS ${MPV_FFMPEG_LIBS_DIR})
list(APPEND mpv_inc_dirs
${MPV_FFMPEG_LIBS_DIR}/include)
list(APPEND mpv_link_libs
${MPV_FFMPEG_LIBS_DIR}/lib/libavformat.a
${MPV_FFMPEG_LIBS_DIR}/lib/libswscale.a
${MPV_FFMPEG_LIBS_DIR}/lib/libavfilter.a
${MPV_FFMPEG_LIBS_DIR}/lib/libswresample.a
${MPV_FFMPEG_LIBS_DIR}/lib/libavcodec.a
${MPV_FFMPEG_LIBS_DIR}/lib/libavutil.a
SceAudiodec_stub
SceVideodec_stub
SceCodecEngine_stub
m
z)
else()
pkg_check_modules(_pkg_ffmpeg REQUIRED
libavutil>=56.12.100
libavcodec>=58.12.100
libavformat>=58.9.100
libswscale>=5.0.101
libavfilter>=7.14.100
libswresample>=3.0.100)
_add_pkg_deps(mpv_inc_dirs mpv_link_libs _pkg_ffmpeg)
endif()
# libass
pkg_check_modules(_pkg_ass REQUIRED libass>=0.12.2)
_add_pkg_deps(mpv_inc_dirs mpv_link_libs _pkg_ass)
# zlib
pkg_check_modules(_pkg_zlib REQUIRED zlib)
_add_pkg_deps(mpv_inc_dirs mpv_link_libs _pkg_zlib)
if(BUILD_VITA)
list(APPEND mpv_src_files
osdep/vita/vita_audio.c
osdep/vita/vita_render.c
osdep/vita/vita_platform.c)
list(APPEND mpv_link_libs
vita2d
ScePgf_stub
SceGxm_stub
SceCtrl_stub
SceAudio_stub
ScePower_stub
SceAppMgr_stub
SceAppUtil_stub
SceDisplay_stub
SceSysmodule_stub
SceCommonDialog_stub)
list(APPEND mpv_compile_flags
-fno-optimize-sibling-calls)
else()
if(POLICY CMP0072)
set(OpenGL_GL_PREFERENCE LEGACY)
endif()
find_package(OpenAL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Freetype REQUIRED)
find_package(glfw3 REQUIRED)
pkg_check_modules(_pkg_fontconfig fontconfig)
if(${_pkg_fontconfig_FOUND})
list(APPEND mpv_src_files
osdep/vita/simulator_fontconfig_unix.c)
else()
list(APPEND mpv_src_files
osdep/vita/simulator_fontconfig_fallback.c)
endif()
list(APPEND mpv_src_files
osdep/vita/simulator.h
osdep/vita/simulator_audio.c
osdep/vita/simulator_render.c
osdep/vita/simulator_platform.c)
list(APPEND mpv_inc_dirs
${OPENAL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIRS}
${_pkg_fontconfig_INCLUDE_DIRS})
list(APPEND mpv_link_libs
${OPENAL_LIBRARY}
${OPENGL_LIBRARIES}
${FREETYPE_LIBRARIES}
glfw
${_pkg_fontconfig_LIBRARIES})
list(APPEND mpv_compile_defs
${Fontconfig_COMPILE_OPTIONS}
_GNU_SOURCE
GLFW_INCLUDE_ES2
HAVE_GLIBC_THREAD_NAME=1)
endif()
add_executable(${PROJECT_NAME}
${mpv_src_files}
${mpv_gen_files})
target_compile_options(${PROJECT_NAME} PRIVATE
${mpv_compile_flags})
target_compile_definitions(${PROJECT_NAME} PRIVATE
${mpv_compile_defs})
target_include_directories(${PROJECT_NAME} PRIVATE
${mpv_gen_dir}
${mpv_inc_dirs})
target_link_libraries(${PROJECT_NAME}
${mpv_link_libs}
-pthread
m)
if(BUILD_VITA)
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d ATTRIBUTE2=12")
vita_create_self(eboot.bin ${PROJECT_NAME})
vita_create_vpk(${PROJECT_NAME}.vpk
"${mpv_vita_title_id}" eboot.bin
NAME "${mpv_vita_name}"
VERSION "${mpv_vita_version}"
)
endif()