Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·1198 lines (1138 loc) · 53.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
executable file
·1198 lines (1138 loc) · 53.7 KB
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.20)
if(APPLE)
project(ModernGekko LANGUAGES C CXX OBJCXX)
else()
project(ModernGekko LANGUAGES C CXX)
endif()
include(CTest)
include(CheckIncludeFileCXX)
if(WIN32)
add_compile_definitions(_WIN32_WINNT=0x0A00 WINVER=0x0A00)
set(MODERNGEKKO_DYNAMIC_MODULES_DEFAULT ON)
else()
check_include_file_cxx(dlfcn.h MODERNGEKKO_HAS_DLFCN)
set(MODERNGEKKO_DYNAMIC_MODULES_DEFAULT ${MODERNGEKKO_HAS_DLFCN})
endif()
option(MODERNGEKKO_ENABLE_DYNAMIC_MODULES
"Load game modules through the host dynamic-library API"
${MODERNGEKKO_DYNAMIC_MODULES_DEFAULT})
option(MODERNGEKKO_STATICRECOMP_THINLTO
"Enable ThinLTO for the five StaticRecomp core translation units"
OFF)
option(MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME
"Build the RecompCore/Dolphin production chassis" ON)
option(MODERNGEKKO_ENABLE_DOLPHIN_TESTS
"Build the imported Dolphin unit-test targets" OFF)
option(MODERNGEKKO_ENABLE_DISC_TOOL
"Build Dolphin's disc conversion and verification tool" OFF)
set(MODERNGEKKO_FRONTEND_NAME "Deep Sea" CACHE STRING
"Branded frontend display name")
set(MODERNGEKKO_LAUNCHER_OUTPUT_NAME "DeepSea" CACHE STRING
"Launcher executable filename without a platform suffix")
set(MODERNGEKKO_RUNNER_OUTPUT_NAME "moderngekko-run" CACHE STRING
"Runner executable filename without a platform suffix")
set(MODERNGEKKO_USER_DIRECTORY_NAME "moderngekko" CACHE STRING
"Frontend user directory name")
set(MODERNGEKKO_REQUIRED_DISC_ID "" CACHE STRING
"Required six-character disc ID for branded builds")
set(MODERNGEKKO_REQUIRED_DOL_SHA256 "" CACHE STRING
"Required extracted main DOL SHA-256")
set(MODERNGEKKO_REQUIRED_REL_SHA256 "" CACHE STRING
"Required extracted main REL SHA-256")
set(MODERNGEKKO_REQUIRED_ASSETS_SHA256 "" CACHE STRING
"Required extracted files tree SHA-256")
set(MODERNGEKKO_DEFAULT_WINDOW_TITLE "Deep Sea" CACHE STRING
"Fixed game window title for branded builds")
option(MODERNGEKKO_PORTABLE_DEFAULT_GAME
"Read and write default-game.txt beside branded executables" OFF)
option(MODERNGEKKO_GAMECUBE_CONTROLLERS
"Generate GameCube controller profiles instead of Wii Remote profiles" OFF)
set(MODERNGEKKO_LOG_FILENAME "DeepSea.log" CACHE STRING
"Runner log filename")
set(MODERNGEKKO_APP_ICON "${CMAKE_CURRENT_SOURCE_DIR}/packaging/branding/deepsea.ico" CACHE FILEPATH
"Windows icon embedded in the runner and the launcher (empty: none)")
set(MODERNGEKKO_DISC_PREPARER_OUTPUT_NAME "" CACHE STRING
"Optional adjacent disc preparation executable")
set(MODERNGEKKO_DOL_PATCH_MANIFEST "" CACHE FILEPATH
"Optional expected-word DOL patch manifest bundled with the frontend")
set(MODERNGEKKO_GAME_SETTINGS_OVERRIDE "" CACHE FILEPATH
"Optional game INI copied over the bundled Dolphin settings")
set(MODERNGEKKO_ACCEPTED_SOURCE_DISC_ID "" CACHE STRING
"Source disc ID accepted by the optional disc preparer")
option(MODERNGEKKO_USER_DIRECTORY_IN_DOCUMENTS
"Place the branded user directory in Documents" OFF)
set(MODERNGEKKO_FRONTEND_SDK "" CACHE PATH
"Optional non-root sysroot containing X11 and audio development packages")
if(MODERNGEKKO_FRONTEND_SDK)
set(_moderngekko_sdk_usr "${MODERNGEKKO_FRONTEND_SDK}/usr")
set(_moderngekko_sdk_lib "${_moderngekko_sdk_usr}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
if(NOT IS_DIRECTORY "${_moderngekko_sdk_usr}/include" OR
NOT IS_DIRECTORY "${_moderngekko_sdk_lib}")
message(FATAL_ERROR
"MODERNGEKKO_FRONTEND_SDK is not a usable sysroot: ${MODERNGEKKO_FRONTEND_SDK}")
endif()
list(PREPEND CMAKE_PREFIX_PATH "${_moderngekko_sdk_usr}")
list(PREPEND CMAKE_INCLUDE_PATH "${_moderngekko_sdk_usr}/include")
list(PREPEND CMAKE_LIBRARY_PATH "${_moderngekko_sdk_lib}")
link_directories("${_moderngekko_sdk_lib}")
set(_moderngekko_pkgconfig
"${_moderngekko_sdk_lib}/pkgconfig:${_moderngekko_sdk_usr}/share/pkgconfig")
if(DEFINED ENV{PKG_CONFIG_PATH} AND NOT "$ENV{PKG_CONFIG_PATH}" STREQUAL "")
string(APPEND _moderngekko_pkgconfig ":$ENV{PKG_CONFIG_PATH}")
endif()
set(ENV{PKG_CONFIG_PATH} "${_moderngekko_pkgconfig}")
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${MODERNGEKKO_FRONTEND_SDK}")
# FindALSA does not use pkg-config on all supported CMake releases.
if(EXISTS "${_moderngekko_sdk_lib}/libasound.so")
set(ALSA_INCLUDE_DIR "${_moderngekko_sdk_usr}/include" CACHE PATH "" FORCE)
set(ALSA_LIBRARY "${_moderngekko_sdk_lib}/libasound.so" CACHE FILEPATH "" FORCE)
endif()
endif()
if(MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME)
set(MODERNGEKKO_ENABLE_IMGUI_LAUNCHER ON CACHE BOOL "" FORCE)
set(ENABLE_QT OFF CACHE BOOL "" FORCE)
set(ENABLE_NOGUI OFF CACHE BOOL "" FORCE)
set(ENABLE_CLI_TOOL ${MODERNGEKKO_ENABLE_DISC_TOOL} CACHE BOOL "" FORCE)
set(ENABLE_TESTS ${MODERNGEKKO_ENABLE_DOLPHIN_TESTS} CACHE BOOL "" FORCE)
set(ENABLE_AUTOUPDATE OFF CACHE BOOL "" FORCE)
set(ENABLE_ANALYTICS OFF CACHE BOOL "" FORCE)
set(USE_RETRO_ACHIEVEMENTS OFF CACHE BOOL "" FORCE)
set(USE_DISCORD_PRESENCE OFF CACHE BOOL "" FORCE)
set(USE_MGBA OFF CACHE BOOL "" FORCE)
set(USE_UPNP OFF CACHE BOOL "" FORCE)
set(ENCODE_FRAMEDUMPS OFF CACHE BOOL "" FORCE)
set(ENABLE_LLVM OFF CACHE BOOL "" FORCE)
# Cubeb is Dolphin's only audio backend on macOS
if(APPLE OR WIN32)
set(ENABLE_CUBEB ON CACHE BOOL "" FORCE)
else()
set(ENABLE_CUBEB OFF CACHE BOOL "" FORCE)
endif()
set(ENABLE_HWDB OFF CACHE BOOL "" FORCE)
set(ENABLE_EVDEV OFF CACHE BOOL "" FORCE)
if(NOT WIN32)
set(ENABLE_WAYLAND ON CACHE BOOL "" FORCE)
else()
# Windows cross builds must not enter the host Wayland branch
# (wayland-scanner + xdg-shell.xml are Linux display stack only).
set(ENABLE_WAYLAND OFF CACHE BOOL "" FORCE)
endif()
set(ENABLE_EGL OFF CACHE BOOL "" FORCE)
set(USE_SYSTEM_SDL3 OFF CACHE BOOL "" FORCE)
# SDL bundles its own copy of the macOS hidapi backend
if(APPLE)
set(SDL_HIDAPI OFF CACHE BOOL "" FORCE)
endif()
set(LINUX_LOCAL_DEV ON CACHE BOOL "" FORCE)
set(DISTRIBUTOR "ModernGekko" CACHE STRING "" FORCE)
add_subdirectory(vendor/dolphin EXCLUDE_FROM_ALL)
# release-opt loud-LTO guard: ENABLE_LTO=ON must yield real IPO, never a
# silent non-LTO build that later reports numbers as "opt". Dolphin's own
# ENABLE_LTO block sets IPO only in its directory scope, so re-check here:
# this also propagates IPO to ModernGekko's own targets defined below.
if(ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT _mg_ipo_supported OUTPUT _mg_ipo_error)
if(NOT _mg_ipo_supported)
message(FATAL_ERROR "ENABLE_LTO=ON but IPO is unsupported by this toolchain: ${_mg_ipo_error}")
endif()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
target_sources(core PRIVATE
vendor/dolphin/GXRuntime/src/core/cpu_exception.c)
target_include_directories(core PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/GXRuntime/include")
if(MODERNGEKKO_FRONTEND_SDK)
# These two imported targets historically rely on X11 headers living
# in the compiler's default /usr/include search path.
target_include_directories(common SYSTEM PRIVATE "${_moderngekko_sdk_usr}/include")
if(TARGET videovulkan)
target_include_directories(videovulkan SYSTEM PRIVATE
"${_moderngekko_sdk_usr}/include")
endif()
endif()
else()
set(FMT_INSTALL OFF CACHE BOOL "" FORCE)
set(FMT_TEST OFF CACHE BOOL "" FORCE)
add_subdirectory(vendor/fmt/fmt EXCLUDE_FROM_ALL)
endif()
if(BUILD_TESTING)
add_subdirectory(vendor/dolphin/DolRecomp)
else()
add_subdirectory(vendor/dolphin/DolRecomp EXCLUDE_FROM_ALL)
endif()
add_library(moderngekko_abi INTERFACE)
add_library(ModernGekko::ABI ALIAS moderngekko_abi)
target_include_directories(moderngekko_abi
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
add_library(moderngekko_legacy STATIC
src/audio/audio_system.cpp
src/audio/audio_output.cpp
src/hardware/mmio_bus.cpp
src/hardware/disc_interface.cpp
src/hardware/processor_interface.cpp
src/gpu/gx_command_processor.cpp
src/gpu/gx_state_backend.cpp
src/gpu/gx_vertex_loader.cpp
src/gpu/gx_texture_decoder.cpp
src/gpu/gx_pipeline.cpp
src/input/controller.cpp
src/memory/address_space.cpp
src/runtime/module.cpp
src/runtime/module_loader.cpp
src/runtime/mod_loader.cpp
src/runtime/game.cpp
src/runtime/legacy_runtime.cpp
src/timing/event_scheduler.cpp
vendor/dolphin_legacy/Core/Boot/BootMemory.cpp
vendor/dolphin_legacy/Core/Boot/DolReader.cpp
vendor/dolphin_legacy/Core/PowerPC/Interpreter/IntegerBranch.cpp
vendor/dolphin_legacy/Core/PowerPC/ConditionRegister.cpp
)
add_library(ModernGekko::LegacyRuntime ALIAS moderngekko_legacy)
add_library(moderngekko STATIC
src/runtime/module.cpp
src/runtime/module_loader.cpp
src/runtime/mod_loader.cpp
src/runtime/game.cpp
)
add_library(ModernGekko::Runtime ALIAS moderngekko)
add_library(moderngekko_dolphin_video STATIC
src/gpu/dolphin_video_host.cpp
src/gpu/dolphin_shader_compiler.cpp
vendor/dolphin_legacy/VideoCommon/BPMemory.cpp
vendor/dolphin_legacy/VideoCommon/XFMemory.cpp
vendor/dolphin_legacy/VideoCommon/ShaderGenCommon.cpp
vendor/dolphin_legacy/VideoCommon/LightingShaderGen.cpp
vendor/dolphin_legacy/VideoCommon/PixelShaderGen.cpp
vendor/dolphin_legacy/VideoCommon/VertexShaderGen.cpp
vendor/dolphin_legacy/VideoCommon/GeometryShaderGen.cpp
vendor/dolphin_legacy/VideoCommon/DriverDetails.cpp
vendor/dolphin_legacy/VideoCommon/UberShaderCommon.cpp
vendor/dolphin_legacy/VideoCommon/UberShaderPixel.cpp
vendor/dolphin_legacy/VideoCommon/UberShaderVertex.cpp
)
if(APPLE)
target_sources(moderngekko_dolphin_video PRIVATE
vendor/dolphin_legacy/Common/CommonFuncsObjC.mm)
target_link_libraries(moderngekko_dolphin_video PUBLIC "-framework Foundation")
endif()
add_library(ModernGekko::DolphinVideo ALIAS moderngekko_dolphin_video)
set_target_properties(moderngekko_dolphin_video PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
target_compile_features(moderngekko_dolphin_video PUBLIC cxx_std_23)
if(MSVC)
target_compile_options(moderngekko_dolphin_video PUBLIC /Zc:preprocessor)
target_compile_definitions(moderngekko_dolphin_video PUBLIC UNICODE _UNICODE)
endif()
target_include_directories(moderngekko_dolphin_video
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin_legacy"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/picojson"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/dolphin_shims"
)
target_link_libraries(moderngekko_dolphin_video PUBLIC fmt::fmt)
target_link_libraries(moderngekko_legacy PUBLIC ModernGekko::ABI fmt::fmt)
target_compile_features(moderngekko_legacy PUBLIC cxx_std_23)
target_include_directories(moderngekko_legacy PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin_legacy")
target_link_libraries(moderngekko PUBLIC ModernGekko::ABI PRIVATE fmt::fmt)
if(MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME)
target_sources(moderngekko PRIVATE
src/runtime/dolphin_runtime.cpp
vendor/dolphin/Source/Core/DolphinNoGUI/Platform.cpp
vendor/dolphin/Source/Core/DolphinNoGUI/PlatformHeadless.cpp
)
if(WIN32)
target_sources(moderngekko PRIVATE
vendor/dolphin/Source/Core/DolphinNoGUI/PlatformWin32.cpp)
target_link_libraries(moderngekko PRIVATE dwmapi)
endif()
if(APPLE)
# Dolphin's windowed backend for macOS
target_sources(moderngekko PRIVATE
vendor/dolphin/Source/Core/DolphinNoGUI/PlatformMacos.mm)
set_source_files_properties(
vendor/dolphin/Source/Core/DolphinNoGUI/PlatformMacos.mm
PROPERTIES COMPILE_OPTIONS "-fobjc-arc")
target_link_libraries(moderngekko PRIVATE
"${APPKIT_LIBRARY}" "${COREFOUNDATION_LIBRARY}" "${IOK_LIBRARY}")
target_compile_definitions(moderngekko PRIVATE MODERNGEKKO_HAVE_COCOA=1)
endif()
target_include_directories(moderngekko PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/GXRuntime/include")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(moderngekko PRIVATE _ARCH_64=1)
else()
target_compile_definitions(moderngekko PRIVATE _ARCH_32=1)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x64|x86_64|amd64|AMD64")
target_compile_definitions(moderngekko PRIVATE _M_X86_64=1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
target_compile_definitions(moderngekko PRIVATE _M_ARM_64=1)
else()
target_compile_definitions(moderngekko PRIVATE _M_GENERIC=1)
endif()
target_link_libraries(moderngekko PRIVATE core uicommon)
if(TARGET PkgConfig::X11)
target_sources(moderngekko PRIVATE
vendor/dolphin/Source/Core/DolphinNoGUI/PlatformX11.cpp)
target_link_libraries(moderngekko PRIVATE PkgConfig::X11)
if(TARGET PkgConfig::XRANDR)
target_link_libraries(moderngekko PRIVATE PkgConfig::XRANDR)
target_compile_definitions(moderngekko PRIVATE HAVE_XRANDR=1)
endif()
target_compile_definitions(moderngekko PRIVATE HAVE_X11=1)
endif()
if(TARGET PkgConfig::WAYLAND)
find_program(MODERNGEKKO_WAYLAND_SCANNER wayland-scanner
HINTS "${_moderngekko_sdk_usr}/bin" REQUIRED)
find_file(MODERNGEKKO_XDG_SHELL_XML xdg-shell.xml
HINTS "${_moderngekko_sdk_usr}/share/wayland-protocols/stable/xdg-shell"
"/usr/share/wayland-protocols/stable/xdg-shell"
REQUIRED)
find_file(MODERNGEKKO_XDG_DECORATION_XML xdg-decoration-unstable-v1.xml
HINTS "${_moderngekko_sdk_usr}/share/wayland-protocols/unstable/xdg-decoration"
"/usr/share/wayland-protocols/unstable/xdg-decoration"
REQUIRED)
find_file(MODERNGEKKO_IDLE_INHIBIT_XML idle-inhibit-unstable-v1.xml
HINTS "${_moderngekko_sdk_usr}/share/wayland-protocols/unstable/idle-inhibit"
"/usr/share/wayland-protocols/unstable/idle-inhibit"
REQUIRED)
find_library(MODERNGEKKO_WAYLAND_CURSOR_LIBRARY wayland-cursor
HINTS "${_moderngekko_sdk_lib}" REQUIRED)
find_library(MODERNGEKKO_XKBCOMMON_LIBRARY xkbcommon
HINTS "${_moderngekko_sdk_lib}" REQUIRED)
set(_moderngekko_wayland_generated
"${CMAKE_CURRENT_BINARY_DIR}/generated/wayland")
set(_moderngekko_xdg_header
"${_moderngekko_wayland_generated}/xdg-shell-client-protocol.h")
set(_moderngekko_xdg_code
"${_moderngekko_wayland_generated}/xdg-shell-protocol.c")
set(_moderngekko_decoration_header
"${_moderngekko_wayland_generated}/xdg-decoration-client-protocol.h")
set(_moderngekko_decoration_code
"${_moderngekko_wayland_generated}/xdg-decoration-protocol.c")
set(_moderngekko_idle_inhibit_header
"${_moderngekko_wayland_generated}/idle-inhibit-unstable-v1-client-protocol.h")
set(_moderngekko_idle_inhibit_code
"${_moderngekko_wayland_generated}/idle-inhibit-unstable-v1-protocol.c")
add_custom_command(
OUTPUT "${_moderngekko_xdg_header}" "${_moderngekko_xdg_code}"
COMMAND "${CMAKE_COMMAND}" -E make_directory
"${_moderngekko_wayland_generated}"
COMMAND "${MODERNGEKKO_WAYLAND_SCANNER}" client-header
"${MODERNGEKKO_XDG_SHELL_XML}" "${_moderngekko_xdg_header}"
COMMAND "${MODERNGEKKO_WAYLAND_SCANNER}" private-code
"${MODERNGEKKO_XDG_SHELL_XML}" "${_moderngekko_xdg_code}"
DEPENDS "${MODERNGEKKO_XDG_SHELL_XML}"
VERBATIM)
add_custom_command(
OUTPUT "${_moderngekko_decoration_header}" "${_moderngekko_decoration_code}"
COMMAND "${CMAKE_COMMAND}" -E make_directory
"${_moderngekko_wayland_generated}"
COMMAND "${MODERNGEKKO_WAYLAND_SCANNER}" client-header
"${MODERNGEKKO_XDG_DECORATION_XML}" "${_moderngekko_decoration_header}"
COMMAND "${MODERNGEKKO_WAYLAND_SCANNER}" private-code
"${MODERNGEKKO_XDG_DECORATION_XML}" "${_moderngekko_decoration_code}"
DEPENDS "${MODERNGEKKO_XDG_DECORATION_XML}"
VERBATIM)
add_custom_command(
OUTPUT "${_moderngekko_idle_inhibit_header}" "${_moderngekko_idle_inhibit_code}"
COMMAND "${CMAKE_COMMAND}" -E make_directory
"${_moderngekko_wayland_generated}"
COMMAND "${MODERNGEKKO_WAYLAND_SCANNER}" client-header
"${MODERNGEKKO_IDLE_INHIBIT_XML}" "${_moderngekko_idle_inhibit_header}"
COMMAND "${MODERNGEKKO_WAYLAND_SCANNER}" private-code
"${MODERNGEKKO_IDLE_INHIBIT_XML}" "${_moderngekko_idle_inhibit_code}"
DEPENDS "${MODERNGEKKO_IDLE_INHIBIT_XML}"
VERBATIM)
target_sources(moderngekko PRIVATE
vendor/dolphin/Source/Core/DolphinNoGUI/PlatformWayland.cpp
"${_moderngekko_xdg_code}"
"${_moderngekko_decoration_code}"
"${_moderngekko_idle_inhibit_code}")
target_include_directories(moderngekko PRIVATE
"${_moderngekko_wayland_generated}")
if(MODERNGEKKO_FRONTEND_SDK)
target_link_libraries(moderngekko PRIVATE
"${_moderngekko_sdk_lib}/libwayland-client.so")
else()
target_link_libraries(moderngekko PRIVATE PkgConfig::WAYLAND)
endif()
target_link_libraries(moderngekko PRIVATE
"${MODERNGEKKO_WAYLAND_CURSOR_LIBRARY}"
"${MODERNGEKKO_XKBCOMMON_LIBRARY}")
target_compile_definitions(moderngekko PRIVATE HAVE_WAYLAND=1)
target_compile_definitions(videovulkan PRIVATE HAVE_WAYLAND=1)
if(MODERNGEKKO_FRONTEND_SDK)
target_link_directories(moderngekko PRIVATE "${_moderngekko_sdk_lib}")
endif()
endif()
endif()
if(MODERNGEKKO_ENABLE_DYNAMIC_MODULES)
target_sources(moderngekko_legacy PRIVATE vendor/dolphin_legacy/Common/DynamicLibrary.cpp)
target_link_libraries(moderngekko_legacy PRIVATE ${CMAKE_DL_LIBS})
target_compile_definitions(moderngekko_legacy PRIVATE MODERNGEKKO_ENABLE_DYNAMIC_MODULES=1)
if(NOT MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME)
target_sources(moderngekko PRIVATE vendor/dolphin_legacy/Common/DynamicLibrary.cpp)
target_link_libraries(moderngekko PRIVATE ${CMAKE_DL_LIBS})
endif()
target_compile_definitions(moderngekko PRIVATE MODERNGEKKO_ENABLE_DYNAMIC_MODULES=1)
endif()
target_compile_features(moderngekko PUBLIC cxx_std_23)
if(MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME)
target_include_directories(moderngekko PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Source/Core")
else()
target_include_directories(moderngekko PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin_legacy")
endif()
add_executable(moderngekko-module-info
tools/module_info.cpp
)
target_link_libraries(moderngekko-module-info
PRIVATE ModernGekko::Runtime
)
if(WIN32)
# CommandLineToArgvW (shellapi.h) — UTF-8 argv rebuild in module_info.cpp
target_link_libraries(moderngekko-module-info PRIVATE shell32)
endif()
if(MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME)
if(TARGET SDL3-static)
set(_moderngekko_sdl_target SDL3-static)
elseif(TARGET SDL3::SDL3-shared)
set(_moderngekko_sdl_target SDL3::SDL3-shared)
elseif(TARGET SDL3::SDL3)
set(_moderngekko_sdl_target SDL3::SDL3)
else()
message(FATAL_ERROR "No usable SDL3 target is available for the frontend")
endif()
# Host audio output for the legacy runtime lane: SPSC ring -> SDL3 device
# stream (WASAPI shared mode on Windows). Without a Dolphin runtime there
# is no SDL3 target and audio_output.cpp compiles as a graceful no-op stub.
target_link_libraries(moderngekko_legacy PUBLIC ${_moderngekko_sdl_target})
target_compile_definitions(moderngekko_legacy PRIVATE MODERNGEKKO_HAVE_SDL_AUDIO=1)
if(WIN32 AND MODERNGEKKO_APP_ICON AND CMAKE_RC_COMPILER)
set(_moderngekko_icon_rc "${CMAKE_CURRENT_BINARY_DIR}/moderngekko-icon.rc")
file(WRITE "${_moderngekko_icon_rc}" "1 ICON \"${MODERNGEKKO_APP_ICON}\"\n")
endif()
add_executable(moderngekko-run
tools/moderngekko_run.cpp
tools/netplay_compatibility.cpp
tools/netplay_session.cpp
tools/frontend_config.cpp
tools/dol_patch.cpp
src/runner/game_setup.cpp
src/runner/game_setup_win32.cpp
vendor/dolphin/Externals/imgui/imgui/backends/imgui_impl_sdl3.cpp
vendor/dolphin/Externals/imgui/imgui/backends/imgui_impl_sdlrenderer3.cpp)
if(_moderngekko_icon_rc)
target_sources(moderngekko-run PRIVATE "${_moderngekko_icon_rc}")
endif()
if(WIN32)
# IFileOpenDialog (CoCreateInstance, CLSID/IID GUIDs) in game_setup_win32.
# dbghelp: MiniDumpWriteDump in the last-chance crash filter.
target_link_libraries(moderngekko-run PRIVATE ole32 uuid dbghelp)
endif()
# PerMonitorV2 DPI awareness for moderngekko-run. Graceful fallback: without
# a manifest tool the build succeeds, just without DPI awareness.
if(WIN32)
set(_moderngekko_dpi_manifest
"${CMAKE_CURRENT_SOURCE_DIR}/tools/moderngekko-run.manifest")
if(MSVC)
target_link_options(moderngekko-run PRIVATE
"/MANIFEST:EMBED" "/MANIFESTINPUT:${_moderngekko_dpi_manifest}")
elseif(CMAKE_RC_COMPILER)
set(_moderngekko_dpi_rc
"${CMAKE_CURRENT_BINARY_DIR}/moderngekko-run.manifest.rc")
file(WRITE "${_moderngekko_dpi_rc}"
"1 24 \"${_moderngekko_dpi_manifest}\"\n")
target_sources(moderngekko-run PRIVATE "${_moderngekko_dpi_rc}")
else()
message(STATUS
"moderngekko-run: no manifest tool, skipping DPI awareness manifest")
endif()
endif()
target_include_directories(moderngekko-run PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Source/Core"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/GXRuntime/include"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Externals/imgui/imgui/backends")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(moderngekko-run PRIVATE _ARCH_64=1)
else()
target_compile_definitions(moderngekko-run PRIVATE _ARCH_32=1)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x64|x86_64|amd64|AMD64")
target_compile_definitions(moderngekko-run PRIVATE _M_X86_64=1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
target_compile_definitions(moderngekko-run PRIVATE _M_ARM_64=1)
else()
target_compile_definitions(moderngekko-run PRIVATE _M_GENERIC=1)
endif()
if(MODERNGEKKO_FRONTEND_SDK AND UNIX AND NOT APPLE AND
MODERNGEKKO_PORTABLE_DEFAULT_GAME)
set_property(TARGET moderngekko-run PROPERTY
BUILD_WITH_INSTALL_RPATH TRUE)
elseif(MODERNGEKKO_FRONTEND_SDK)
set_property(TARGET moderngekko-run PROPERTY BUILD_RPATH
"${_moderngekko_sdk_lib}")
endif()
target_link_libraries(moderngekko-run PRIVATE
ModernGekko::Runtime core uicommon imgui ${_moderngekko_sdl_target})
if(MODERNGEKKO_STATICRECOMP_THINLTO)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR
"MODERNGEKKO_STATICRECOMP_THINLTO requires a Clang-compatible compiler")
endif()
target_link_options(moderngekko-run PRIVATE "-flto=thin")
endif()
set_target_properties(moderngekko-run PROPERTIES
OUTPUT_NAME "${MODERNGEKKO_RUNNER_OUTPUT_NAME}")
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_RUNNER_NAME="${MODERNGEKKO_RUNNER_OUTPUT_NAME}"
MODERNGEKKO_USER_DIRECTORY_NAME="${MODERNGEKKO_USER_DIRECTORY_NAME}")
if(MODERNGEKKO_DEFAULT_WINDOW_TITLE)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_DEFAULT_WINDOW_TITLE="${MODERNGEKKO_DEFAULT_WINDOW_TITLE}")
endif()
if(MODERNGEKKO_REQUIRED_DISC_ID)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_REQUIRED_DISC_ID="${MODERNGEKKO_REQUIRED_DISC_ID}")
endif()
if(MODERNGEKKO_REQUIRED_DOL_SHA256)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_REQUIRED_DOL_SHA256="${MODERNGEKKO_REQUIRED_DOL_SHA256}")
endif()
if(MODERNGEKKO_REQUIRED_REL_SHA256)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_REQUIRED_REL_SHA256="${MODERNGEKKO_REQUIRED_REL_SHA256}")
endif()
if(MODERNGEKKO_REQUIRED_ASSETS_SHA256)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_REQUIRED_ASSETS_SHA256="${MODERNGEKKO_REQUIRED_ASSETS_SHA256}")
endif()
if(MODERNGEKKO_PORTABLE_DEFAULT_GAME)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_PORTABLE_DEFAULT_GAME=1)
endif()
if(MODERNGEKKO_GAMECUBE_CONTROLLERS)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_GAMECUBE_CONTROLLERS=1)
endif()
if(MODERNGEKKO_USER_DIRECTORY_IN_DOCUMENTS)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_USER_DIRECTORY_IN_DOCUMENTS=1)
endif()
if(MODERNGEKKO_DOL_PATCH_MANIFEST)
get_filename_component(_moderngekko_dol_patch_name
"${MODERNGEKKO_DOL_PATCH_MANIFEST}" NAME)
target_compile_definitions(moderngekko-run PRIVATE
MODERNGEKKO_DOL_PATCH_MANIFEST="patches/${_moderngekko_dol_patch_name}")
endif()
set(MODERNGEKKO_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "" FORCE)
add_subdirectory(mods/frame60-accum
"${CMAKE_CURRENT_BINARY_DIR}/frame60-accum-mod")
add_subdirectory(mods/cutscene-skip
"${CMAKE_CURRENT_BINARY_DIR}/cutscene-skip-mod")
add_subdirectory(mods/widescreen16x9
"${CMAKE_CURRENT_BINARY_DIR}/widescreen16x9-mod")
add_subdirectory(mods/input-script
"${CMAKE_CURRENT_BINARY_DIR}/input-script-mod")
add_dependencies(moderngekko-run mod cutscene_skip_mod widescreen16x9_mod input_script_mod)
add_custom_command(TARGET moderngekko-run POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Data/Sys"
"$<TARGET_FILE_DIR:moderngekko-run>/Sys"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/frame60-accum.mgm"
"$<TARGET_FILE_DIR:moderngekko-run>/Mods/frame60-accum.mgm"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/cutscene-skip.mgm"
"$<TARGET_FILE_DIR:moderngekko-run>/Mods/cutscene-skip.mgm"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/widescreen16x9.mgm"
"$<TARGET_FILE_DIR:moderngekko-run>/Mods/widescreen16x9.mgm"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_CURRENT_BINARY_DIR}/input-script.mgm"
"$<TARGET_FILE_DIR:moderngekko-run>/Mods/input-script.mgm")
if(MODERNGEKKO_DOL_PATCH_MANIFEST)
add_custom_command(TARGET moderngekko-run POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:moderngekko-run>/patches"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${MODERNGEKKO_DOL_PATCH_MANIFEST}"
"$<TARGET_FILE_DIR:moderngekko-run>/patches/${_moderngekko_dol_patch_name}")
endif()
if(MODERNGEKKO_GAME_SETTINGS_OVERRIDE)
get_filename_component(_moderngekko_settings_name
"${MODERNGEKKO_GAME_SETTINGS_OVERRIDE}" NAME)
add_custom_command(TARGET moderngekko-run POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${MODERNGEKKO_GAME_SETTINGS_OVERRIDE}"
"$<TARGET_FILE_DIR:moderngekko-run>/Sys/GameSettings/${_moderngekko_settings_name}")
endif()
add_executable(moderngekko-launcher
tools/moderngekko_launcher.cpp
tools/frontend_config.cpp
tools/dol_patch.cpp
vendor/dolphin/Externals/imgui/imgui/backends/imgui_impl_sdl3.cpp
vendor/dolphin/Externals/imgui/imgui/backends/imgui_impl_sdlrenderer3.cpp)
target_include_directories(moderngekko-launcher PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Source/Core"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Externals/imgui/imgui/backends"
# header-only JSON reader for the game-setup builder status file
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Externals/picojson")
# The launcher only calls the game-inspection surface directly, but the
# Dolphin static libraries still require the Host_* callbacks implemented
# in the runtime object. Keep that object from being discarded by the
# static linker.
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
target_link_libraries(moderngekko-launcher PRIVATE
"$<LINK_LIBRARY:WHOLE_ARCHIVE,moderngekko>"
discio core uicommon imgui ${_moderngekko_sdl_target})
elseif((UNIX AND NOT APPLE) OR MINGW)
target_link_libraries(moderngekko-launcher PRIVATE
"-Wl,--whole-archive" moderngekko "-Wl,--no-whole-archive"
discio core uicommon imgui ${_moderngekko_sdl_target})
else()
target_link_libraries(moderngekko-launcher PRIVATE
ModernGekko::Runtime discio imgui ${_moderngekko_sdl_target})
endif()
set_target_properties(moderngekko-launcher PROPERTIES
OUTPUT_NAME "${MODERNGEKKO_LAUNCHER_OUTPUT_NAME}")
if(_moderngekko_icon_rc)
target_sources(moderngekko-launcher PRIVATE "${_moderngekko_icon_rc}")
endif()
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_FRONTEND_NAME="${MODERNGEKKO_FRONTEND_NAME}"
MODERNGEKKO_RUNNER_FILENAME="${MODERNGEKKO_RUNNER_OUTPUT_NAME}"
MODERNGEKKO_USER_DIRECTORY_NAME="${MODERNGEKKO_USER_DIRECTORY_NAME}"
MODERNGEKKO_LOG_FILENAME="${MODERNGEKKO_LOG_FILENAME}")
if(MODERNGEKKO_REQUIRED_DISC_ID)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_REQUIRED_DISC_ID="${MODERNGEKKO_REQUIRED_DISC_ID}")
endif()
if(MODERNGEKKO_REQUIRED_DOL_SHA256)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_REQUIRED_DOL_SHA256="${MODERNGEKKO_REQUIRED_DOL_SHA256}")
endif()
if(MODERNGEKKO_REQUIRED_REL_SHA256)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_REQUIRED_REL_SHA256="${MODERNGEKKO_REQUIRED_REL_SHA256}")
endif()
if(MODERNGEKKO_REQUIRED_ASSETS_SHA256)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_REQUIRED_ASSETS_SHA256="${MODERNGEKKO_REQUIRED_ASSETS_SHA256}")
endif()
if(MODERNGEKKO_PORTABLE_DEFAULT_GAME)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_PORTABLE_DEFAULT_GAME=1)
endif()
if(MODERNGEKKO_GAMECUBE_CONTROLLERS)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_GAMECUBE_CONTROLLERS=1)
endif()
if(MODERNGEKKO_USER_DIRECTORY_IN_DOCUMENTS)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_USER_DIRECTORY_IN_DOCUMENTS=1)
endif()
if(MODERNGEKKO_DOL_PATCH_MANIFEST)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_DOL_PATCH_MANIFEST="patches/${_moderngekko_dol_patch_name}")
endif()
if(MODERNGEKKO_DISC_PREPARER_OUTPUT_NAME)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_DISC_PREPARER_FILENAME="${MODERNGEKKO_DISC_PREPARER_OUTPUT_NAME}")
endif()
if(MODERNGEKKO_ACCEPTED_SOURCE_DISC_ID)
target_compile_definitions(moderngekko-launcher PRIVATE
MODERNGEKKO_ACCEPTED_SOURCE_DISC_ID="${MODERNGEKKO_ACCEPTED_SOURCE_DISC_ID}")
endif()
if(MODERNGEKKO_FRONTEND_SDK AND UNIX AND NOT APPLE AND
MODERNGEKKO_PORTABLE_DEFAULT_GAME)
set_property(TARGET moderngekko-launcher PROPERTY
BUILD_WITH_INSTALL_RPATH TRUE)
elseif(MODERNGEKKO_FRONTEND_SDK)
set_property(TARGET moderngekko-launcher PROPERTY BUILD_RPATH
"${_moderngekko_sdk_lib}")
endif()
if(UNIX AND NOT APPLE)
set_target_properties(moderngekko-run moderngekko-launcher PROPERTIES
INSTALL_RPATH "$ORIGIN/lib")
endif()
add_dependencies(moderngekko-launcher moderngekko-run)
add_executable(moderngekko-port tools/moderngekko_port.cpp)
target_link_libraries(moderngekko-port PRIVATE ModernGekko::Runtime)
if(WIN32)
# CommandLineToArgvW (shellapi.h via utf8_path.hpp) — UTF-8 argv rebuild
target_link_libraries(moderngekko-port PRIVATE shell32)
endif()
target_compile_definitions(moderngekko-port PRIVATE
MODERNGEKKO_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
if(DOLRECOMP_ENABLE_LLVM)
target_compile_definitions(moderngekko-port PRIVATE
MODERNGEKKO_DOLRECOMP_LLVM=1)
endif()
add_dependencies(moderngekko-port dolrecomp moderngekko-run)
# A custom target rather than POST_BUILD on moderngekko-port. POST_BUILD only
# fires when its own target relinks, so bumping DolRecomp rebuilt the
# recompiler while leaving the stale copy in place -- and moderngekko-port
# runs the copy beside itself, so it silently kept recompiling with the old
# binary and reported success. It cannot hang off dolrecomp either:
# add_custom_command(TARGET) requires the target be defined in the same
# directory, and dolrecomp comes from add_subdirectory. A custom target is
# always considered out of date, and copy_if_different makes that cheap.
add_custom_target(moderngekko-port-recompiler ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:dolrecomp>"
"$<TARGET_FILE_DIR:moderngekko-port>"
DEPENDS dolrecomp
COMMENT "Refreshing dolrecomp beside moderngekko-port")
add_dependencies(moderngekko-port moderngekko-port-recompiler)
endif()
if(WIN32)
set_target_properties(moderngekko PROPERTIES
OUTPUT_NAME moderngekko_runtime)
target_compile_definitions(moderngekko_legacy PRIVATE
WIN32_LEAN_AND_MEAN NOMINMAX)
target_compile_definitions(moderngekko_dolphin_video PRIVATE
WIN32_LEAN_AND_MEAN NOMINMAX)
foreach(_moderngekko_windows_target
moderngekko
moderngekko-module-info
moderngekko-run
moderngekko-launcher
moderngekko-port)
if(TARGET ${_moderngekko_windows_target})
target_compile_definitions(${_moderngekko_windows_target} PRIVATE
WIN32_LEAN_AND_MEAN NOMINMAX)
if(MSVC)
target_compile_options(${_moderngekko_windows_target} PRIVATE
/Zc:preprocessor)
endif()
endif()
endforeach()
endif()
if(BUILD_TESTING)
add_executable(moderngekko_dol_patch_test
tests/dol_patch_test.cpp
tools/dol_patch.cpp)
target_include_directories(moderngekko_dol_patch_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools")
target_compile_features(moderngekko_dol_patch_test PRIVATE cxx_std_23)
add_test(NAME moderngekko.dol_patch COMMAND moderngekko_dol_patch_test)
add_executable(moderngekko_frontend_config_test
tests/frontend_config_test.cpp
tools/frontend_config.cpp)
target_include_directories(moderngekko_frontend_config_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(moderngekko_frontend_config_test PRIVATE cxx_std_23)
add_test(NAME moderngekko.frontend_config COMMAND moderngekko_frontend_config_test)
# Header-only, so the test needs no companion translation unit.
add_executable(moderngekko_launcher_savestates_test
tests/launcher_savestates_test.cpp)
target_include_directories(moderngekko_launcher_savestates_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
# For Core/SavestateLayout.h, which owns the listing rules. It depends on
# nothing but the standard library, so this pulls in no Dolphin linkage.
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Source/Core")
target_compile_features(moderngekko_launcher_savestates_test PRIVATE cxx_std_23)
add_test(NAME moderngekko.launcher_savestates
COMMAND moderngekko_launcher_savestates_test)
# First-launch game setup: the test binary stands in for the disc builder.
if(TARGET moderngekko-launcher)
add_executable(moderngekko_launcher_module_setup_test
tests/launcher_module_setup_test.cpp)
target_include_directories(moderngekko_launcher_module_setup_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Externals/picojson")
target_link_libraries(moderngekko_launcher_module_setup_test PRIVATE
${_moderngekko_sdl_target})
target_compile_features(moderngekko_launcher_module_setup_test PRIVATE cxx_std_23)
add_test(NAME moderngekko.launcher_module_setup
COMMAND moderngekko_launcher_module_setup_test)
endif()
# Synthetic bench-harness coverage: fake runner + state drives
# bench/mg_bench.sh through its restore/progress/parked-detection paths.
find_program(MODERNGEKKO_BASH_EXECUTABLE bash)
if(MODERNGEKKO_BASH_EXECUTABLE)
add_test(NAME moderngekko.mg_bench_synthetic
COMMAND "${MODERNGEKKO_BASH_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/bench/tests/mg_bench_synthetic_test.sh")
# Release-bundle staging: drives scripts/package-release.sh against a
# synthetic build tree and checks the layout, manifest, provenance,
# and the no-game-data sweep. Needs no built binaries.
add_test(NAME moderngekko.package_release
COMMAND "${MODERNGEKKO_BASH_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/tests/package-release-test.sh")
endif()
add_executable(moderngekko_frontend_config_gamecube_test
tests/frontend_config_test.cpp
tools/frontend_config.cpp)
target_include_directories(moderngekko_frontend_config_gamecube_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(moderngekko_frontend_config_gamecube_test PRIVATE cxx_std_23)
target_compile_definitions(moderngekko_frontend_config_gamecube_test PRIVATE
MODERNGEKKO_GAMECUBE_CONTROLLERS=1)
add_test(NAME moderngekko.frontend_config_gamecube
COMMAND moderngekko_frontend_config_gamecube_test)
add_executable(moderngekko_ensure_edge_test
tests/ensure_edge_test.cpp
tools/frontend_config.cpp)
target_include_directories(moderngekko_ensure_edge_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(moderngekko_ensure_edge_test PRIVATE cxx_std_23)
target_compile_definitions(moderngekko_ensure_edge_test PRIVATE
MODERNGEKKO_GAMECUBE_CONTROLLERS=1)
add_test(NAME moderngekko.ensure_edge
COMMAND moderngekko_ensure_edge_test)
# First-run game-path flow: probe + PromptForValidGameRoot with scripted
# UI hooks. On Windows the GameSetupUi defaults reference the Win32 leaf,
# so it must be linked even though the scripted hooks never call it.
add_executable(moderngekko_game_setup_test
tests/game_setup_test.cpp
src/runner/game_setup.cpp)
target_include_directories(moderngekko_game_setup_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(moderngekko_game_setup_test PRIVATE cxx_std_23)
if(WIN32)
target_sources(moderngekko_game_setup_test PRIVATE
src/runner/game_setup_win32.cpp)
target_link_libraries(moderngekko_game_setup_test PRIVATE ole32 uuid)
endif()
add_test(NAME moderngekko.game_setup
COMMAND moderngekko_game_setup_test)
if(MODERNGEKKO_ENABLE_DOLPHIN_RUNTIME)
add_executable(moderngekko_netplay_protocol_test
tests/netplay_protocol_test.cpp
tools/netplay_compatibility.cpp)
target_include_directories(moderngekko_netplay_protocol_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tools"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/Source/Core"
"${CMAKE_CURRENT_SOURCE_DIR}/vendor/dolphin/GXRuntime/include")
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE
MODERNGEKKO_NETPLAY_TEST_MOD_PATH="$<TARGET_FILE:moderngekko_test_mod>")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE _ARCH_64=1)
else()
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE _ARCH_32=1)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x64|x86_64|amd64|AMD64")
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE _M_X86_64=1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE _M_ARM_64=1)
else()
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE _M_GENERIC=1)
endif()
if(MINGW)
target_link_libraries(moderngekko_netplay_protocol_test PRIVATE
"-Wl,--whole-archive" moderngekko "-Wl,--no-whole-archive" core uicommon)
elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
target_link_libraries(moderngekko_netplay_protocol_test PRIVATE
"$<LINK_LIBRARY:WHOLE_ARCHIVE,moderngekko>" core uicommon)
elseif(UNIX AND NOT APPLE)
target_link_libraries(moderngekko_netplay_protocol_test PRIVATE
"-Wl,--whole-archive" moderngekko "-Wl,--no-whole-archive" core uicommon)
else()
target_link_libraries(moderngekko_netplay_protocol_test PRIVATE
ModernGekko::Runtime core uicommon)
endif()
if(WIN32)
# The same treatment the non-test Windows targets get from the loop
# above, which runs before the test targets exist and so misses
# them. WIN32_LEAN_AND_MEAN keeps windows.h from pulling in
# winsock.h, which would clash with the winsock2.h this reaches
# through Dolphin's networking headers ('sockaddr' redefinition).
target_compile_definitions(moderngekko_netplay_protocol_test PRIVATE
WIN32_LEAN_AND_MEAN NOMINMAX)
if(MSVC)
# Dolphin's headers use __VA_OPT__, which the traditional
# preprocessor cannot parse.
target_compile_options(moderngekko_netplay_protocol_test PRIVATE
/Zc:preprocessor)
endif()
endif()
add_test(NAME moderngekko.netplay_protocol COMMAND moderngekko_netplay_protocol_test)
endif()
add_executable(moderngekko_game_inspect_test tests/game_inspect_test.cpp)
target_link_libraries(moderngekko_game_inspect_test PRIVATE ModernGekko::LegacyRuntime)
add_test(NAME moderngekko.game_inspect COMMAND moderngekko_game_inspect_test)
add_executable(moderngekko_module_abi_test
tests/module_abi_test.c
)
target_link_libraries(moderngekko_module_abi_test
PRIVATE ModernGekko::LegacyRuntime
)
add_test(NAME moderngekko.module_abi
COMMAND moderngekko_module_abi_test)
add_library(moderngekko_test_module SHARED
tests/fixtures/test_module.c
)
target_link_libraries(moderngekko_test_module
PRIVATE ModernGekko::ABI
)
set_target_properties(moderngekko_test_module PROPERTIES
PREFIX ""
OUTPUT_NAME "moderngekko_test_module"
)
add_library(moderngekko_missing_export_module SHARED
tests/fixtures/missing_export.c)
set_target_properties(moderngekko_missing_export_module PROPERTIES
PREFIX "" OUTPUT_NAME "moderngekko_missing_export_module")
add_executable(moderngekko_module_loader_test
tests/module_loader_test.cpp
)
target_link_libraries(moderngekko_module_loader_test
PRIVATE ModernGekko::LegacyRuntime
)
target_compile_definitions(moderngekko_module_loader_test
PRIVATE
MODERNGEKKO_TEST_MODULE_PATH="$<TARGET_FILE:moderngekko_test_module>"
MODERNGEKKO_MISSING_EXPORT_MODULE_PATH="$<TARGET_FILE:moderngekko_missing_export_module>"
)
add_dependencies(moderngekko_module_loader_test moderngekko_test_module
moderngekko_missing_export_module)
add_test(NAME moderngekko.module_loader
COMMAND moderngekko_module_loader_test)
add_library(moderngekko_test_mod SHARED
tests/fixtures/test_mod.c
)
target_link_libraries(moderngekko_test_mod
PRIVATE ModernGekko::ABI
)
set_target_properties(moderngekko_test_mod PROPERTIES
PREFIX ""
OUTPUT_NAME "fixture.mgm"
)
add_executable(moderngekko_mod_loader_test
tests/mod_loader_test.cpp
)
target_link_libraries(moderngekko_mod_loader_test
PRIVATE ModernGekko::LegacyRuntime
)
target_compile_definitions(moderngekko_mod_loader_test
PRIVATE
MODERNGEKKO_TEST_MOD_DIR="$<TARGET_FILE:moderngekko_test_mod>"
)
add_dependencies(moderngekko_mod_loader_test moderngekko_test_mod)
if(TARGET moderngekko_netplay_protocol_test)
add_dependencies(moderngekko_netplay_protocol_test moderngekko_test_mod)
endif()
add_test(NAME moderngekko.mod_loader
COMMAND moderngekko_mod_loader_test)
add_executable(moderngekko_j3d_stageb_test tests/j3d_stageb_test.cpp)
target_compile_features(moderngekko_j3d_stageb_test PRIVATE cxx_std_23)
add_test(NAME moderngekko.j3d_stageb COMMAND moderngekko_j3d_stageb_test)
add_executable(moderngekko_frame60_accum_test tests/frame60_accum_test.c)
target_include_directories(moderngekko_frame60_accum_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
add_test(NAME moderngekko.frame60_accum COMMAND moderngekko_frame60_accum_test)
add_executable(moderngekko_widescreen16x9_test tests/widescreen16x9_test.c)
target_include_directories(moderngekko_widescreen16x9_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
add_test(NAME moderngekko.widescreen16x9
COMMAND moderngekko_widescreen16x9_test)
add_executable(moderngekko_input_script_test tests/input_script_test.c)
target_include_directories(moderngekko_input_script_test PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
add_test(NAME moderngekko.input_script
COMMAND moderngekko_input_script_test)
add_executable(moderngekko_cpu_primitives_test
tests/cpu_primitives_test.cpp
)
target_link_libraries(moderngekko_cpu_primitives_test
PRIVATE ModernGekko::LegacyRuntime
)