-
Notifications
You must be signed in to change notification settings - Fork 191
/
CMakeLists.txt
1615 lines (1496 loc) · 51.4 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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR)
project(EasyRPG_Player VERSION 0.8
DESCRIPTION "Interpreter for RPG Maker 2000/2003 games"
HOMEPAGE_URL "https://easyrpg.org"
LANGUAGES CXX)
# Extra CMake Module files
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules")
include(CMakeDependentOption)
include(PlayerConfigureWindows)
include(PlayerFindPackage)
include(PlayerBuildType)
include(PlayerMisc)
include(GetGitRevisionDescription)
# Dependencies provided by CMake Presets
list(APPEND CMAKE_PREFIX_PATH "${PLAYER_PREFIX_PATH_APPEND}")
# C++17 is required
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Must be at global scope, otherwise breaks -DPLAYER_BUILD_LIBLCF (see CMP0077)
option(BUILD_SHARED_LIBS "Build shared easyrpg_libretro core" ON)
option(CMAKE_FIND_PACKAGE_PREFER_CONFIG "Prefer config files over bundled FindXXX files. Set this to OFF when configuration fails and report a bug." ON)
# Source Files
add_library(${PROJECT_NAME} OBJECT
src/lcf_data.cpp
src/lcf/data.h
src/async_handler.cpp
src/async_handler.h
src/async_op.h
src/algo.h
src/algo.cpp
src/attribute.h
src/attribute.cpp
src/audio.cpp
src/audio_decoder.cpp
src/audio_decoder.h
src/audio_decoder_base.cpp
src/audio_decoder_base.h
src/audio_decoder_midi.cpp
src/audio_decoder_midi.h
src/audio_generic.cpp
src/audio_generic.h
src/audio_generic_midiout.cpp
src/audio_generic_midiout.h
src/audio.h
src/audio_midi.cpp
src/audio_midi.h
src/audio_resampler.cpp
src/audio_resampler.h
src/audio_secache.cpp
src/audio_secache.h
src/autobattle.cpp
src/autobattle.h
src/background.cpp
src/background.h
src/baseui.cpp
src/baseui.h
src/battle_animation.cpp
src/battle_animation.h
src/battle_message.cpp
src/battle_message.h
src/bitmap.cpp
src/bitmapfont.h
src/bitmapfont_glyph.h
src/bitmap.h
src/bitmap_hslrgb.h
src/cache.cpp
src/cache.h
src/cmdline_parser.cpp
src/cmdline_parser.h
src/color.h
src/compiler.h
src/config_param.h
src/decoder_fluidsynth.cpp
src/decoder_fluidsynth.h
src/decoder_libsndfile.cpp
src/decoder_libsndfile.h
src/decoder_mpg123.cpp
src/decoder_mpg123.h
src/decoder_oggvorbis.cpp
src/decoder_oggvorbis.h
src/decoder_opus.cpp
src/decoder_opus.h
src/decoder_wildmidi.cpp
src/decoder_wildmidi.h
src/decoder_xmp.cpp
src/decoder_xmp.h
src/default_graphics.h
src/directory_tree.cpp
src/directory_tree.h
src/docmain.h
src/drawable.cpp
src/drawable.h
src/drawable_list.cpp
src/drawable_list.h
src/drawable_mgr.cpp
src/drawable_mgr.h
src/dynrpg_easyrpg.cpp
src/dynrpg_easyrpg.h
src/dynrpg_textplugin.cpp
src/dynrpg_textplugin.h
src/enemyai.cpp
src/enemyai.h
src/exe_reader.cpp
src/exe_reader.h
src/exfont.h
src/feature.cpp
src/feature.h
src/filefinder.cpp
src/filefinder.h
src/filefinder_rtp.cpp
src/filefinder_rtp.h
src/fileext_guesser.cpp
src/fileext_guesser.h
src/filesystem.cpp
src/filesystem.h
src/filesystem_hook.cpp
src/filesystem_hook.h
src/filesystem_lzh.cpp
src/filesystem_lzh.h
src/filesystem_native.cpp
src/filesystem_native.h
src/filesystem_root.cpp
src/filesystem_root.h
src/filesystem_stream.cpp
src/filesystem_stream.h
src/filesystem_zip.cpp
src/filesystem_zip.h
src/flash.h
src/flat_map.h
src/font.cpp
src/font.h
src/fps_overlay.cpp
src/fps_overlay.h
src/frame.cpp
src/frame.h
src/game_actor.cpp
src/game_actor.h
src/game_actors.cpp
src/game_actors.h
src/game_battlealgorithm.cpp
src/game_battlealgorithm.h
src/game_battle.cpp
src/game_battle.h
src/game_battler.cpp
src/game_battler.h
src/game_character.cpp
src/game_character.h
src/game_clock.cpp
src/game_clock.h
src/game_commonevent.cpp
src/game_commonevent.h
src/game_config.cpp
src/game_config.h
src/game_config_game.cpp
src/game_config_game.h
src/game_dynrpg.cpp
src/game_dynrpg.h
src/game_enemy.cpp
src/game_enemy.h
src/game_enemyparty.cpp
src/game_enemyparty.h
src/game_event.cpp
src/game_event.h
src/game_ineluki.cpp
src/game_ineluki.h
src/game_interpreter_battle.cpp
src/game_interpreter_battle.h
src/game_interpreter_control_variables.cpp
src/game_interpreter_control_variables.h
src/game_interpreter.cpp
src/game_interpreter.h
src/game_interpreter_map.cpp
src/game_interpreter_map.h
src/game_interpreter_shared.cpp
src/game_interpreter_shared.h
src/game_map.cpp
src/game_map.h
src/game_message.cpp
src/game_message.h
src/game_party_base.cpp
src/game_party_base.h
src/game_party.cpp
src/game_party.h
src/game_pictures.cpp
src/game_pictures.h
src/game_player.cpp
src/game_player.h
src/game_quit.cpp
src/game_quit.h
src/game_screen.cpp
src/game_screen.h
src/game_strings.cpp
src/game_strings.h
src/game_switches.cpp
src/game_switches.h
src/game_system.cpp
src/game_system.h
src/game_targets.cpp
src/game_targets.h
src/game_variables.cpp
src/game_variables.h
src/game_vehicle.cpp
src/game_vehicle.h
src/game_windows.cpp
src/game_windows.h
src/generated/bitmapfont_rmg2000.h
src/generated/bitmapfont_ttyp0.h
src/generated/bitmapfont_wqy.h
src/generated/logo.h
src/generated/logo2.h
src/generated/shinonome_gothic.h
src/generated/shinonome_mincho.h
src/graphics.cpp
src/graphics.h
src/hslrgb.cpp
src/hslrgb.h
src/icon.h
src/image_bmp.cpp
src/image_bmp.h
src/image_png.cpp
src/image_png.h
src/image_xyz.cpp
src/image_xyz.h
src/input_buttons_desktop.cpp
src/input_buttons.h
src/input.cpp
src/input.h
src/input_source.cpp
src/input_source.h
src/instrumentation.cpp
src/instrumentation.h
src/keys.h
src/main_data.cpp
src/main_data.h
src/maniac_patch.cpp
src/maniac_patch.h
src/map_data.h
src/memory_management.h
src/message_overlay.cpp
src/message_overlay.h
src/meta.cpp
src/meta.h
src/midisequencer.cpp
src/midisequencer.h
src/opacity.h
src/options.h
src/output.cpp
src/output.h
src/pending_message.h
src/pending_message.cpp
src/pixel_format.h
src/pixman_image_ptr.h
src/plane.cpp
src/plane.h
src/platform.cpp
src/platform.h
src/platform/clock.h
src/player.cpp
src/player.h
src/point.h
src/rand.cpp
src/rand.h
src/rect.cpp
src/rect.h
src/registry.h
src/registry_wine.cpp
src/rtp.cpp
src/rtp.h
src/rtp_table.cpp
src/scene_actortarget.cpp
src/scene_actortarget.h
src/scene_battle.cpp
src/scene_battle.h
src/scene_battle_rpg2k3.cpp
src/scene_battle_rpg2k3.h
src/scene_battle_rpg2k.cpp
src/scene_battle_rpg2k.h
src/scene.cpp
src/scene_debug.cpp
src/scene_debug.h
src/scene_end.cpp
src/scene_end.h
src/scene_equip.cpp
src/scene_equip.h
src/scene_file.cpp
src/scene_file.h
src/scene_gamebrowser.cpp
src/scene_gamebrowser.h
src/scene_gameover.cpp
src/scene_gameover.h
src/scene.h
src/scene_import.cpp
src/scene_import.h
src/scene_item.cpp
src/scene_item.h
src/scene_load.cpp
src/scene_load.h
src/scene_logo.cpp
src/scene_logo.h
src/scene_map.cpp
src/scene_map.h
src/scene_menu.cpp
src/scene_menu.h
src/scene_name.cpp
src/scene_name.h
src/scene_order.cpp
src/scene_order.h
src/scene_save.cpp
src/scene_save.h
src/scene_shop.cpp
src/scene_shop.h
src/scene_skill.cpp
src/scene_skill.h
src/scene_status.cpp
src/scene_status.h
src/scene_settings.h
src/scene_settings.cpp
src/scene_teleport.cpp
src/scene_teleport.h
src/scene_title.cpp
src/scene_title.h
src/screen.cpp
src/screen.h
src/shake.h
src/span.h
src/sprite_airshipshadow.cpp
src/sprite_airshipshadow.h
src/sprite_actor.cpp
src/sprite_actor.h
src/sprite_battler.cpp
src/sprite_battler.h
src/sprite_enemy.cpp
src/sprite_enemy.h
src/sprite_character.cpp
src/sprite_character.h
src/sprite_picture.h
src/sprite_picture.cpp
src/sprite_weapon.cpp
src/sprite_weapon.h
src/sprite.cpp
src/sprite.h
src/spriteset_battle.cpp
src/spriteset_battle.h
src/spriteset_map.cpp
src/spriteset_map.h
src/sprite_timer.cpp
src/sprite_timer.h
src/state.cpp
src/state.h
src/std_clock.h
src/string_view.cpp
src/string_view.h
src/system.h
src/teleport_target.h
src/text.cpp
src/text.h
src/tilemap.cpp
src/tilemap.h
src/tilemap_layer.cpp
src/tilemap_layer.h
src/tone.h
src/transform.h
src/transition.cpp
src/transition.h
src/translation.cpp
src/translation.h
src/util_macro.h
src/utils.cpp
src/utils.h
src/version.cpp
src/version.h
src/weather.cpp
src/weather.h
src/window_about.cpp
src/window_about.h
src/window_actorinfo.cpp
src/window_actorinfo.h
src/window_actorsp.cpp
src/window_actorsp.h
src/window_actorstatus.cpp
src/window_actorstatus.h
src/window_actortarget.cpp
src/window_actortarget.h
src/window_base.cpp
src/window_base.h
src/window_battlecommand.cpp
src/window_battlecommand.h
src/window_battlemessage.cpp
src/window_battlemessage.h
src/window_battlestatus.cpp
src/window_battlestatus.h
src/window_command.cpp
src/window_command.h
src/window_command_horizontal.cpp
src/window_command_horizontal.h
src/window.cpp
src/window_equip.cpp
src/window_equip.h
src/window_equipitem.cpp
src/window_equipitem.h
src/window_equipstatus.cpp
src/window_equipstatus.h
src/window_face.cpp
src/window_face.h
src/window_gamelist.cpp
src/window_gamelist.h
src/window_gold.cpp
src/window_gold.h
src/window.h
src/window_help.cpp
src/window_help.h
src/window_import_progress.cpp
src/window_import_progress.h
src/window_input_settings.cpp
src/window_input_settings.h
src/window_item.cpp
src/window_item.h
src/window_interpreter.cpp
src/window_interpreter.h
src/window_keyboard.cpp
src/window_keyboard.h
src/window_menustatus.cpp
src/window_menustatus.h
src/window_message.cpp
src/window_message.h
src/window_name.cpp
src/window_name.h
src/window_numberinput.cpp
src/window_numberinput.h
src/window_paramstatus.cpp
src/window_paramstatus.h
src/window_savefile.cpp
src/window_savefile.h
src/window_selectable.cpp
src/window_selectable.h
src/window_settings.cpp
src/window_settings.h
src/window_shopbuy.cpp
src/window_shopbuy.h
src/window_shop.cpp
src/window_shop.h
src/window_shopnumber.cpp
src/window_shopnumber.h
src/window_shopparty.cpp
src/window_shopparty.h
src/window_shopsell.cpp
src/window_shopsell.h
src/window_shopstatus.cpp
src/window_shopstatus.h
src/window_skill.cpp
src/window_skill.h
src/window_skillstatus.cpp
src/window_skillstatus.h
src/window_stringview.cpp
src/window_stringview.h
src/window_targetstatus.cpp
src/window_targetstatus.h
src/window_teleport.cpp
src/window_teleport.h
src/window_varlist.cpp
src/window_varlist.h
)
# These are actually unused when building in CMake
# src/platform/opendingux/opendingux_input_buttons.cpp
# src/platform/psp/psp_input_buttons.cpp
# Include directories
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
# Optimize floating point math functions into intrinsics and don't check or set errno (i.e. sqrt(-1))
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PUBLIC "-fno-math-errno")
endif()
# Version setup
set(PLAYER_VERSION ${PROJECT_VERSION})
if(NOT PROJECT_VERSION_TWEAK)
# a kludge to match the valid version format
set(PROJECT_VERSION_TWEAK 0)
if(NOT PROJECT_VERSION_PATCH)
set(PROJECT_VERSION_PATCH 0)
endif()
endif()
set(PLAYER_VERSION_FULL ${PLAYER_VERSION})
string(CONCAT PROJECT_VERSION
${PROJECT_VERSION_MAJOR} "." ${PROJECT_VERSION_MINOR} "."
${PROJECT_VERSION_PATCH} "." ${PROJECT_VERSION_TWEAK})
set(PLAYER_VERSION_GIT "")
git_get_exact_tag(GIT_TAG)
# Do not include a hash, if we are building a release tag
if(NOT GIT_TAG)
# otherwise concatenate a version with hash
git_describe(GIT_DESCRIPTION)
if(GIT_DESCRIPTION)
string(REPLACE "-" ";" GIT_DESCRIPTION ${GIT_DESCRIPTION})
list(LENGTH GIT_DESCRIPTION GIT_DESCRIPTION_PARTS)
set(GIT_MESSAGE "Found git info: ")
if(GIT_DESCRIPTION_PARTS EQUAL 3)
list(GET GIT_DESCRIPTION 0 GIT_TAG)
list(GET GIT_DESCRIPTION 1 GIT_COMMITS)
list(GET GIT_DESCRIPTION 2 GIT_HASH)
string(APPEND GIT_MESSAGE "${GIT_COMMITS} commits since tag \"${GIT_TAG}\", ")
string(PREPEND GIT_COMMITS "+")
# strip the g prefix
string(SUBSTRING ${GIT_HASH} 1 -1 GIT_HASH)
else()
# no tags found, only hash
list(GET GIT_DESCRIPTION 0 GIT_HASH)
endif()
set(PLAYER_VERSION_GIT "git${GIT_COMMITS}@${GIT_HASH}")
string(APPEND GIT_MESSAGE "object hash is ${GIT_HASH}")
git_local_changes(GIT_DIRTY)
if(GIT_DIRTY STREQUAL "DIRTY")
string(APPEND PLAYER_VERSION_GIT "-dirty")
string(APPEND GIT_MESSAGE ", you have uncommitted changes")
endif()
string(APPEND PLAYER_VERSION_FULL "-${PLAYER_VERSION_GIT}")
message(STATUS "${GIT_MESSAGE}")
endif()
endif()
string(TIMESTAMP PLAYER_DATE "(%Y-%m-%d)")
set(PLAYER_VERSION_APPEND ${PLAYER_DATE} CACHE STRING "Additional version information to include")
set_property(SOURCE src/version.cpp PROPERTY COMPILE_DEFINITIONS
EP_VERSION="${PLAYER_VERSION}";
EP_VERSION_MAJOR=${PROJECT_VERSION_MAJOR};
EP_VERSION_MINOR=${PROJECT_VERSION_MINOR};
EP_VERSION_PATCH=${PROJECT_VERSION_PATCH};
EP_VERSION_TWEAK=${PROJECT_VERSION_TWEAK};
EP_VERSION_APPEND="${PLAYER_VERSION_APPEND}";
EP_VERSION_GIT="${PLAYER_VERSION_GIT}"
)
# Platform setup
if(NINTENDO_3DS)
set(PLAYER_TARGET_PLATFORM "3ds" CACHE STRING "Platform to compile for.")
elseif(NINTENDO_SWITCH)
set(PLAYER_TARGET_PLATFORM "switch" CACHE STRING "Platform to compile for.")
elseif(VITA)
set(PLAYER_TARGET_PLATFORM "psvita" CACHE STRING "Platform to compile for.")
elseif(NINTENDO_WII)
set(PLAYER_TARGET_PLATFORM "wii" CACHE STRING "Platform to compile for.")
elseif(NINTENDO_WIIU)
set(PLAYER_TARGET_PLATFORM "SDL2" CACHE STRING "Platform to compile for.")
elseif(AMIGA)
set(PLAYER_TARGET_PLATFORM "SDL1" CACHE STRING "Platform to compile for.")
else()
set(PLAYER_TARGET_PLATFORM "SDL2" CACHE STRING "Platform to compile for. Options: SDL2 SDL1 libretro")
set_property(CACHE PLAYER_TARGET_PLATFORM PROPERTY STRINGS SDL2 SDL1 libretro)
endif()
set(PLAYER_BUILD_EXECUTABLE ON)
set(PLAYER_TEST_LIBRARIES ${PROJECT_NAME})
if(ANDROID AND PLAYER_GRADLE_BUILD)
# Build invoked by Gradle
# Ugly: Gradle has no way to branch based on the ABI
# Inject correct search path based on PLAYER_ANDROID_TOOLCHAIN_PATH
foreach(f ${PLAYER_ANDROID_TOOLCHAIN_PATH})
list(APPEND CMAKE_FIND_ROOT_PATH "${f}/${ANDROID_ABI}-toolchain")
endforeach(f)
endif()
if(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL2")
target_sources(${PROJECT_NAME} PRIVATE
src/platform/sdl/sdl_audio.cpp
src/platform/sdl/sdl_audio.h
src/platform/sdl/sdl2_ui.cpp
src/platform/sdl/sdl2_ui.h)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_SDL=2)
# SDL2 depends on some systems on SDL2::SDL2main but SDL2::SDL2 is not always a dependency of it
# Manually add the dependencies
player_find_package(NAME SDL2
VERSION 2.0.5
TARGET SDL2::SDL2
REQUIRED)
if(TARGET SDL2::SDL2main)
target_link_libraries(${PROJECT_NAME} SDL2::SDL2main)
endif()
if(ANDROID)
set(PLAYER_BUILD_EXECUTABLE OFF)
endif()
if(NINTENDO_WIIU)
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_NINTENDO)
target_sources(${PROJECT_NAME} PRIVATE
src/platform/wiiu/main.h
src/platform/wiiu/input_buttons.cpp)
endif()
if(WIN32)
target_link_libraries(${PROJECT_NAME} "Dwmapi")
endif()
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL1")
target_sources(${PROJECT_NAME} PRIVATE
src/platform/sdl/sdl_audio.cpp
src/platform/sdl/sdl_audio.h
src/platform/sdl/axis.h
src/platform/sdl/sdl_ui.cpp
src/platform/sdl/sdl_ui.h)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_SDL=1)
player_find_package(NAME SDL1 TARGET SDL::SDLmain REQUIRED)
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "libretro")
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_UI=LibretroUi USE_LIBRETRO=1)
set(PLAYER_BUILD_EXECUTABLE OFF)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/builds/libretro)
target_link_libraries(${PROJECT_NAME} retro_common)
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "3ds")
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_UI=CtrUi PLAYER_NINTENDO)
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-psabi) # Remove abi warning after devkitarm ships newer gcc
# generate gfx assets
enable_language(ASM)
ctr_add_graphics_target(keyboard IMAGE
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/keyboard.png
OPTIONS -f rgba)
ctr_add_graphics_target(battery ATLAS
INPUTS
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/empty.png
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/1bar.png
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/2bars.png
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/3bars.png
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/4bars.png
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/full.png
${CMAKE_CURRENT_SOURCE_DIR}/resources/3ds/battery/adapter.png
OPTIONS -f rgba)
dkp_add_embedded_binary_library(3ds-assets keyboard battery)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_sources(${PROJECT_NAME} INTERFACE
$<TARGET_OBJECTS:3ds-assets> PRIVATE
src/platform/3ds/audio.cpp
src/platform/3ds/audio.h
src/platform/3ds/clock.cpp
src/platform/3ds/clock.h
src/platform/3ds/input_buttons.cpp
src/platform/3ds/ui.cpp
src/platform/3ds/ui.h)
target_link_libraries(${PROJECT_NAME} 3ds-assets)
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "psvita")
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_UI=Psp2Ui)
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-psabi) # Remove abi warning after vitasdk ships newer gcc
target_sources(${PROJECT_NAME} PRIVATE
src/platform/psvita/audio.cpp
src/platform/psvita/audio.h
src/platform/psvita/clock.cpp
src/platform/psvita/clock.h
src/platform/psvita/input_buttons.cpp
src/platform/psvita/ui.cpp
src/platform/psvita/ui.h)
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "switch")
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_UI=NxUi PLAYER_NINTENDO)
find_package(OpenGL CONFIG REQUIRED)
find_library(GLAD glad REQUIRED)
target_link_libraries(${PROJECT_NAME} OpenGL::EGL)
# generate gfx assets
enable_language(ASM)
dkp_add_embedded_binary_library(switch-assets "${CMAKE_CURRENT_SOURCE_DIR}/resources/switch/touch_ui.png")
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_sources(${PROJECT_NAME} INTERFACE
$<TARGET_OBJECTS:switch-assets> PRIVATE
src/platform/switch/audio.cpp
src/platform/switch/audio.h
src/platform/switch/clock.cpp
src/platform/switch/clock.h
src/platform/switch/input_buttons.cpp
src/platform/switch/ui.cpp
src/platform/switch/ui.h)
target_link_libraries(${PROJECT_NAME} switch-assets)
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "wii")
find_package(SDL REQUIRED)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_SDL=1 PLAYER_NINTENDO)
target_include_directories(${PROJECT_NAME} PUBLIC ${SDL_INCLUDE_DIR})
target_sources(${PROJECT_NAME} PRIVATE
src/platform/wii/audio.cpp
src/platform/wii/audio.h
src/platform/wii/clock.cpp
src/platform/wii/clock.h
src/platform/wii/input_buttons.cpp
src/platform/sdl/axis.h
src/platform/sdl/sdl_ui.cpp
src/platform/sdl/sdl_ui.h)
else()
message(FATAL_ERROR "Invalid target platform")
endif()
# Shared by homebrew platforms
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|psvita|switch|wii)$" OR NINTENDO_WIIU)
target_compile_options(${PROJECT_NAME} PUBLIC -fno-exceptions -fno-rtti)
set(CMAKE_DL_LIBS "") # hack4icu!
set(PLAYER_ENABLE_TESTS OFF)
option(PLAYER_VERSIONED_PACKAGES "Create zip packages with versioned name (for internal use)" ON)
endif()
# Make content available (romfs/wuhb bundle)
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|switch)$" OR NINTENDO_WIIU)
option(PLAYER_BUNDLE "Embed a directory in the executable" OFF)
set(PLAYER_BUNDLE_PATH "content" CACHE PATH "Directory to include in executable")
set(BUNDLE_ARG "_IGNORE_ME")
if(PLAYER_BUNDLE)
if(NINTENDO_WIIU)
set(BUNDLE_ARG "CONTENT")
else()
set(BUNDLE_ARG "ROMFS")
endif()
endif()
endif()
# Amiga
if(AMIGA)
target_compile_options(${PROJECT_NAME} PUBLIC -fno-exceptions -fno-rtti)
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_AMIGA)
if(MORPHOS)
target_compile_definitions(${PROJECT_NAME} PUBLIC
_GLIBCXX_USE_C99 _NO_PPCINLINE __MORPHOS_SHAREDLIBS)
# -noixemul handled as "M68K_CRT" in toolchain file
target_sources(${PROJECT_NAME} PRIVATE
src/platform/morphos/integration.cpp)
set_property(SOURCE src/platform/morphos/integration.cpp
PROPERTY COMPILE_DEFINITIONS PLAYER_VERSION="${PLAYER_VERSION_FULL}"
)
endif()
if(AMIGAOS4)
# FIXME: needed?
target_compile_definitions(${PROJECT_NAME} PUBLIC
_GLIBCXX_USE_C99_STDINT_TR1 _GLIBCXX_USE_C99_STDIO)
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/platform/amigaos4)
endif()
if(AROS)
message(WARNING "AROS is unsupported currently. Patches welcome!")
endif()
endif()
if(NOT PLAYER_BUILD_EXECUTABLE AND BUILD_SHARED_LIBS)
# Need fPIC when compiling a shared library (e.g. libretro.so)
include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE TRUE)
endif()
if(ANDROID)
target_link_libraries(${PROJECT_NAME} android log)
endif()
if(WIN32)
target_sources(${PROJECT_NAME} PRIVATE
src/registry.cpp
src/platform/windows/utils.cpp
src/platform/windows/utils.h
src/platform/windows/midiout_device_win32.cpp
src/platform/windows/midiout_device_win32.h)
endif()
if(APPLE)
enable_language(OBJCXX)
target_sources(${PROJECT_NAME} PRIVATE
src/platform/macos/macos_utils.mm
src/platform/macos/macos_utils.h
src/platform/macos/midiout_device_coreaudio.cpp
src/platform/macos/midiout_device_coreaudio.h)
find_library(MACOSFOUNDATION Foundation)
find_Library(MACOSAUDIOUNIT AudioUnit)
find_library(MACOSAUDIOTOOLBOX AudioToolbox)
target_link_libraries(${PROJECT_NAME} ${MACOSFOUNDATION} ${MACOSAUDIOUNIT} ${MACOSAUDIOTOOLBOX})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
option(PLAYER_JS_BUILD_SHELL "Build the Player executable as a shell file (.html) instead of a standalone javascript file (.js)" OFF)
set(PLAYER_JS_GAME_URL "games/" CACHE STRING "Game URL/directory where the web player searches for games")
set(PLAYER_JS_OUTPUT_NAME "easyrpg-player" CACHE STRING "Output name of the js, html and wasm files")
set_property(SOURCE src/async_handler.cpp APPEND PROPERTY COMPILE_DEFINITIONS "EM_GAME_URL=\"${PLAYER_JS_GAME_URL}\"")
endif()
# Endianess check
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.20)
if (CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN")
target_compile_definitions(${PROJECT_NAME} PRIVATE WORDS_BIGENDIAN=1)
endif()
else()
include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)
if(WORDS_BIGENDIAN)
target_compile_definitions(${PROJECT_NAME} PRIVATE WORDS_BIGENDIAN=1)
endif()
endif()
# App Icon (for macOS)
set(${PROJECT_NAME}_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/resources/macos/Player.icns")
# Do not code sign on Macs
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.easyrpg.player")
# liblcf
option(PLAYER_BUILD_LIBLCF "Instead of detecting liblcf, clone liblcf into lib/liblcf and build it along with the Player. This is convenient for development." OFF)
set(PLAYER_BUILD_LIBLCF_GIT "https://github.com/EasyRPG/liblcf.git" CACHE STRING "Git repository of liblcf to clone. Requires PLAYER_BUILD_LIBLCF=ON.")
set(PLAYER_BUILD_LIBLCF_BRANCH "master" CACHE STRING "Branch of the liblcf repository to clone. Requires PLAYER_BUILD_LIBLCF=ON.")
if(PLAYER_BUILD_LIBLCF)
# liblcf is built as part of this cmake file
set(LIBLCF_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/liblcf")
if(NOT EXISTS ${LIBLCF_PATH})
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} clone "--depth=1" "--branch"
"${PLAYER_BUILD_LIBLCF_BRANCH}"
"${PLAYER_BUILD_LIBLCF_GIT}"
"${LIBLCF_PATH}")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib/liblcf/builds/cmake/Modules")
# Always build static liblcf and do not install it
function(add_liblcf)
set(BUILD_SHARED_LIBS OFF)
set(LIBLCF_ENABLE_INSTALL OFF)
add_subdirectory(${LIBLCF_PATH})
endfunction()
add_liblcf()
target_link_libraries(${PROJECT_NAME} lcf)
else()
# Use system package
player_find_package(NAME liblcf VERSION 0.8
TARGET liblcf::liblcf
REQUIRED)
endif()
# Detect all required libraries
player_find_package(NAME PNG TARGET PNG::PNG REQUIRED)
player_find_package(NAME fmt TARGET fmt::fmt REQUIRED)
# Do not use player_find_package. enable_language used by pixman on Android does not work properly inside function calls
find_package(Pixman REQUIRED)
target_link_libraries(${PROJECT_NAME} PIXMAN::PIXMAN)
# Always enable Wine registry support on non-Windows, but not for console ports
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
AND NOT ${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$"
AND NOT NINTENDO_WIIU)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_WINE=1)
endif()
# freetype and harfbuzz
option(PLAYER_WITH_FREETYPE "Support FreeType font rendering" ON)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_HARFBUZZ "Enable HarfBuzz text shaping (Requires FreeType)" ON "PLAYER_WITH_FREETYPE" OFF)
# Freetype is not really broken however only using FT config without HB config causes problems
player_find_package(NAME freetype
CONDITION PLAYER_WITH_FREETYPE
DEFINITION HAVE_FREETYPE
TARGET freetype
CONFIG_BROKEN)
if(TARGET freetype)
# Harfbuzz config is broken (see https://github.com/harfbuzz/harfbuzz/issues/2316)
# They do not plan to fix this as they are moving to meson
player_find_package(NAME harfbuzz
CONDITION PLAYER_WITH_HARFBUZZ
DEFINITION HAVE_HARFBUZZ
TARGET harfbuzz::harfbuzz
CONFIG_BROKEN)
endif()
# lzh archive support
option(PLAYER_WITH_LHASA "Support running games in lzh archives" ON)
player_find_package(NAME lhasa
CONDITION PLAYER_WITH_LHASA
DEFINITION HAVE_LHASA
TARGET LHASA::liblhasa
)
# json support
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
player_find_package(NAME nlohmann_json
DEFINITION HAVE_NLOHMANN_JSON
TARGET nlohmann_json::nlohmann_json
REQUIRED
)
else()
option(PLAYER_WITH_NLOHMANN_JSON "Support processing of JSON files" ON)
player_find_package(NAME nlohmann_json
CONDITION PLAYER_WITH_NLOHMANN_JSON
DEFINITION HAVE_NLOHMANN_JSON
TARGET nlohmann_json::nlohmann_json
ONLY_CONFIG
)
endif()
# Sound system to use
if(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL2")
set(PLAYER_AUDIO_BACKEND "SDL2" CACHE STRING "Audio system to use. Options: SDL2 OFF")
set_property(CACHE PLAYER_AUDIO_BACKEND PROPERTY STRINGS SDL2 OFF)
if(${PLAYER_AUDIO_BACKEND} STREQUAL "SDL2_mixer")
message(FATAL_ERROR "SDL2_mixer is not supported anymore. Use SDL2 instead.")
endif()
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL1")
set(PLAYER_AUDIO_BACKEND "SDL1" CACHE STRING "Audio system to use. Options: SDL1 OFF")
set_property(CACHE PLAYER_AUDIO_BACKEND PROPERTY STRINGS SDL1 OFF)
else()
# Assuming that all platforms not targeting SDL have only one audio backend
set(PLAYER_AUDIO_BACKEND "Default" CACHE STRING "Audio system to use. Options: Default OFF")
set_property(CACHE PLAYER_AUDIO_BACKEND PROPERTY STRINGS Default OFF)
endif()
# Configure Audio backends
if(${PLAYER_AUDIO_BACKEND} MATCHES "^(SDL[12]|Default)$")
set(PLAYER_HAS_AUDIO ON)
target_compile_definitions(${PROJECT_NAME} PUBLIC SUPPORT_AUDIO=1)
if(${PLAYER_TARGET_PLATFORM} STREQUAL "libretro")
if (WIN32 OR UNIX OR APPLE)
set(SUPPORT_NATIVE_MIDI ON)
endif()
endif()
if(WIN32 OR APPLE)
set(SUPPORT_NATIVE_MIDI ON)
elseif(UNIX)
find_package(ALSA)
if(ALSA_FOUND)
set(SUPPORT_NATIVE_MIDI ON)
endif()
endif()
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_NATIVE_MIDI "Play MIDI audio using the API of the operating system" ON "SUPPORT_NATIVE_MIDI" OFF)
if(PLAYER_WITH_NATIVE_MIDI)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_NATIVE_MIDI=1)
if(WIN32)
target_link_libraries(${PROJECT_NAME} "winmm")
elseif(ALSA_FOUND)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_ALSA=1)
target_sources(${PROJECT_NAME} PRIVATE
src/platform/linux/midiout_device_alsa.cpp
src/platform/linux/midiout_device_alsa.h
)
target_link_libraries(${PROJECT_NAME} ALSA::ALSA)
find_package(Threads)
if(Threads_FOUND)
target_link_libraries(${PROJECT_NAME} Threads::Threads)
endif()
endif()
endif()
# Provide fmmidi options
option(PLAYER_ENABLE_FMMIDI "Enable internal MIDI sequencer. Will be used when external MIDI library fails." ON)
if(PLAYER_ENABLE_FMMIDI)
target_compile_definitions(${PROJECT_NAME} PUBLIC WANT_FMMIDI=1)
endif()
elseif(NOT PLAYER_AUDIO_BACKEND)
set(PLAYER_HAS_AUDIO OFF)
else()
message(FATAL_ERROR "Invalid Audio Backend ${PLAYER_AUDIO_BACKEND}")
endif()
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_MPG123 "Play MP3 audio with libmpg123" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_LIBSNDFILE "Play WAV audio with libsndfile" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_OGGVORBIS "Play Ogg Vorbis audio with libvorbis" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_OPUS "Play Opus audio with opusfile" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_WILDMIDI "Play MIDI audio with wildmidi" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_FLUIDSYNTH "Play MIDI audio with fluidsynth" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_FLUIDLITE "Play MIDI audio with fluidlite" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_XMP "Play MOD audio with libxmp" ON "PLAYER_HAS_AUDIO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_ENABLE_DRWAV "Play WAV audio with dr_wav (built-in). Unsupported files are played by libsndfile." ON "PLAYER_HAS_AUDIO" OFF)
if(${PLAYER_AUDIO_BACKEND} MATCHES "^(SDL[12]|Default)$")
set(PLAYER_AUDIO_RESAMPLER "Auto" CACHE STRING "Audio resampler to use. Options: Auto speexdsp samplerate OFF")
set_property(CACHE PLAYER_AUDIO_RESAMPLER PROPERTY STRINGS Auto speexdsp samplerate OFF)
if(${PLAYER_AUDIO_RESAMPLER} STREQUAL "Auto")
set(PLAYER_AUDIO_RESAMPLER_IS_AUTO ON)
endif()
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_SPEEXDSP "Use speexdsp as resampler when available." ON "PLAYER_HAS_AUDIO;PLAYER_AUDIO_RESAMPLER_IS_AUTO" OFF)
CMAKE_DEPENDENT_OPTION(PLAYER_WITH_SAMPLERATE "Use libsamplerate as resampler when available." ON "PLAYER_HAS_AUDIO;PLAYER_AUDIO_RESAMPLER_IS_AUTO" OFF)
if(PLAYER_AUDIO_RESAMPLER_IS_AUTO)
player_find_package(NAME speexdsp
CONDITION PLAYER_WITH_SPEEXDSP
DEFINITION HAVE_LIBSPEEXDSP
TARGET speexdsp::speexdsp)
if(NOT TARGET speexdsp::speexdsp)
player_find_package(
NAME Samplerate
CONDITION PLAYER_WITH_SAMPLERATE