forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
2552 lines (2403 loc) · 73.8 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
# vim:noexpandtab:
cmake_minimum_required(VERSION 3.8)
project(PPSSPP)
enable_testing()
#This is supposed to work but doesn't!
if(NOT ANDROID)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
enable_language(ASM)
add_definitions(-D__STDC_CONSTANT_MACROS)
# Include AppleClang and Clang.
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(CLANG ON)
message("Clang enabled")
endif()
if(FORCED_CPU)
message("Detected CPU (${CMAKE_SYSTEM_PROCESSOR}) overridden as: ${FORCED_CPU}")
set(CMAKE_SYSTEM_PROCESSOR ${FORCED_CPU})
endif()
# Detect CPU from CMAKE configuration. Toolchains should set this up
if(CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_OSX_ARCHITECTURES)
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*86.*")
set(X86_DEVICE ON)
set(X86_64_DEVICE ON)
endif()
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64")
set(ARM64 ON)
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")
set(ARM64 ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm64")
# M1 Mac
set(ARM64 ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
message("ARM_DEVICE is a go")
set(ARM_DEVICE ON)
if(UNIX AND NOT APPLE)
execute_process(COMMAND cat /proc/cpuinfo OUTPUT_VARIABLE OUTSTR)
string(FIND "${OUTSTR}" "ODROID-XU" pos)
if(NOT (pos LESS 0))
add_compile_options(-mfloat-abi=hard -marm -mtune=cortex-a15.cortex-a7 -mcpu=cortex-a15 -fomit-frame-pointer)
set(ARM_NO_VULKAN ON)
endif()
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^armv7")
set(ARMV7_DEVICE ON)
add_compile_options(-mfpu=neon)
# Horrifying workaround for bug in android cmake stuff for asm files
if(ANDROID)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -target armv7a-none-linux-android")
endif()
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^amd64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^AMD64")
set(X86_DEVICE ON)
set(X86_64_DEVICE ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
set(X86_DEVICE ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^mips")
set(MIPS_DEVICE ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^riscv64")
set(RISCV64_DEVICE ON)
else()
message("Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
endif()
# the libraries in the ffmpeg/ directory are not compatible with mingw
if(MINGW AND NOT DEFINED USE_SYSTEM_FFMPEG)
set(USE_SYSTEM_FFMPEG ON)
endif()
if(NOT ANDROID AND NOT IOS)
if(ARM_DEVICE OR SIMULATOR)
set(USING_EGL ON)
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT USE_LIBNX)
set(LINUX ON)
add_definitions(-D__STDC_CONSTANT_MACROS)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX ON)
set(USING_EGL OFF)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(ANDROID ON)
endif()
# We only support Vulkan on Unix, macOS (by MoltenVK), Android and Windows.
if(ANDROID OR WIN32 OR (UNIX AND NOT ARM_NO_VULKAN))
set(VULKAN ON)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
if(NOT IOS)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl)
endif()
if(MACOSX AND NOT USE_SYSTEM_LIBSDL2)
set(SDL2_LIBRARY ${CMAKE_SOURCE_DIR}/SDL/macOS/SDL2.framework)
endif()
include(ccache)
include(GNUInstallDirs)
add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")
if(OPENXR)
add_definitions(-DOPENXR)
add_library(openxr SHARED IMPORTED)
if(OPENXR_PLATFORM_PICO)
add_definitions(-DOPENXR_PLATFORM_PICO)
set_property(TARGET openxr PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/ext/openxr/libs/pico/arm64-v8a/libopenxr_loader.so")
message("OpenXR for Pico enabled")
endif()
if(OPENXR_PLATFORM_QUEST)
add_definitions(-DOPENXR_PLATFORM_QUEST)
set_property(TARGET openxr PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/ext/openxr/libs/quest/arm64-v8a/libopenxr_loader.so")
message("OpenXR for Quest enabled")
endif()
endif()
if(GOLD)
add_definitions(-DGOLD)
message("Gold Build")
else()
message("Normal Build")
endif()
# User-editable options (go into CMakeCache.txt)
# :: Processors
option(ARMV7 "Set to ON if targeting an ARMv7 processor" ${ARMV7_DEVICE})
option(ARM "Set to ON if targeting an ARM processor" ${ARM_DEVICE})
option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS_DEVICE})
option(RISCV64 "Set to ON if targeting a RISCV64 processor" ${RISCV64_DEVICE})
option(X86 "Set to ON if targeting an X86 processor" ${X86_DEVICE})
option(X86_64 "Set to ON if targeting an X86_64 processor" ${X86_64_DEVICE})
# :: Environments
option(USING_EGL "Set to ON if target environment uses EGL" ${USING_EGL})
option(USING_FBDEV "Set to ON if target environment uses fbdev (eg. Pandora)" ${USING_FBDEV})
option(USING_GLES2 "Set to ON if target device uses OpenGL ES 2.0" ${USING_GLES2})
option(USING_X11_VULKAN "Set to OFF if target environment doesn't use X11 for Vulkan" ON)
option(USE_WAYLAND_WSI "Enable or disable Wayland WSI support for Vulkan" ${USE_WAYLAND_WSI})
option(USE_VULKAN_DISPLAY_KHR "Enable or disable full screen display of Vulkan" ${USE_VULKAN_DISPLAY_KHR})
# :: Frontends
option(USING_QT_UI "Set to ON if you wish to use the Qt frontend wrapper" ${USING_QT_UI})
option(MOBILE_DEVICE "Set to ON when targeting a mobile device" ${MOBILE_DEVICE})
option(HEADLESS "Set to OFF to not generate the PPSSPPHeadless target" ${HEADLESS})
option(UNITTEST "Set to ON to generate the unittest target" ${UNITTEST})
option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" ${SIMULATOR})
option(LIBRETRO "Set to ON to generate the libretro target" OFF)
# :: Options
option(USE_LIBNX "Set to ON to build for Switch(libnx)" OFF)
option(USE_FFMPEG "Build with FFMPEG support" ON)
option(USE_DISCORD "Build with Discord support" ON)
option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
option(USE_ARMIPS "Build with armips support in API/debugger" ON)
option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP})
option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ON)
option(USE_SYSTEM_LIBPNG "Dynamically link against system libpng" ON)
option(USE_SYSTEM_ZSTD "Dynamically link against system zstd" ${USE_SYSTEM_ZSTD})
option(USE_SYSTEM_MINIUPNPC "Dynamically link against system miniUPnPc" ${USE_SYSTEM_MINIUPNPC})
option(USE_ASAN "Use address sanitizer" OFF)
option(USE_UBSAN "Use undefined behaviour sanitizer" OFF)
if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
if(USING_X11_VULKAN)
message("Using X11 for Vulkan")
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
else()
message("NOT using X11 for Vulkan")
endif()
# add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
if(USE_WAYLAND_WSI)
find_package(Wayland)
if(NOT WAYLAND_FOUND)
message(STATUS "Could not find Wayland libraries, disabling Wayland WSI support for Vulkan.")
else()
include_directories(${WAYLAND_INCLUDE_DIR})
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
endif()
endif()
if(USE_VULKAN_DISPLAY_KHR)
message(STATUS "Using experimental full-screen display for Vulkan.")
add_definitions(-DVK_USE_PLATFORM_DISPLAY_KHR)
endif()
endif()
if(LIBRETRO)
add_definitions(-D__LIBRETRO__)
add_definitions(-DGLEW_NO_GLU)
if(NOT MSVC)
add_compile_options(-fPIC)
endif()
endif()
if(ANDROID)
set(MOBILE_DEVICE ON)
set(USING_GLES2 ON)
endif()
if(ANDROID AND NOT LIBRETRO)
set(CoreLibName ppsspp_jni)
set(CoreLinkType SHARED)
else()
set(CoreLibName Core)
set(CoreLinkType STATIC)
endif()
# Work around for some misfeature of the current glslang build system
include_directories(ext/glslang)
# Not sure if this is the best way - what about system glew?
# Anyway, glew will be going away anyway.
include_directories(ext/glew)
if(OPENXR)
set(OPENGL_LIBRARIES GLESv3 EGL)
elseif(NOT OPENGL_LIBRARIES AND USING_GLES2)
set(OPENGL_LIBRARIES GLESv2 EGL)
endif()
if(NOT OPENGL_LIBRARIES)
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
find_package(OpenGL REQUIRED)
endif()
if(USING_EGL)
if(NOT EGL_LIBRARIES)
set(EGL_LIBRARIES EGL)
endif()
set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} ${EGL_LIBRARIES})
endif()
if(NOT LIBRETRO AND NOT IOS)
find_package(SDL2)
endif()
include(FindThreads)
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(QUARTZ_CORE_LIBRARY QuartzCore)
endif()
include_directories("${CMAKE_SOURCE_DIR}")
if(USING_EGL)
add_definitions(-DUSING_EGL)
endif()
if(USING_FBDEV)
add_definitions(-DUSING_FBDEV -DEGL_NO_X11)
endif()
if(USING_GLES2)
add_definitions(-DUSING_GLES2)
endif()
if(MOBILE_DEVICE)
add_definitions(-DMOBILE_DEVICE)
endif()
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
message("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
# Let's not use elseif here so we can catch dupes.
if(ARMV7)
message("Generating for ARMv7, ${CMAKE_BUILD_TYPE}")
endif()
if(ARM)
message("Generating for ARM, ${CMAKE_BUILD_TYPE}")
endif()
if(MIPS AND X86)
message("Generating for MIPS in x86 mode, ${CMAKE_BUILD_TYPE}")
endif()
if(MIPS)
message("Generating for MIPS, ${CMAKE_BUILD_TYPE}")
endif()
if(RISCV64)
message("Generating for RISCV64, ${CMAKE_BUILD_TYPE}")
endif()
if(X86)
message("Generating for x86, ${CMAKE_BUILD_TYPE}")
endif()
if(X86_64)
message("Generating for x86_64, ${CMAKE_BUILD_TYPE}")
endif()
if(ARM64)
message("Generating for ARMv8, ${CMAKE_BUILD_TYPE}")
endif()
# It looks like the flags for the selected build type are written to the cache after each run, which causes some of the operations
# below to keep expanding them with the same flags over and over on every run, leading to a rebuild of the majority of the files.
# To work around this, remember the initial state of the variables from the first run and reset the variables to that.
# TODO: Setting the attributes per target would probably be a better solution.
foreach (LANGUAGE C CXX)
foreach (BUILD_TYPE DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
set(_CMAKE_${LANGUAGE}_FLAGS_${BUILD_TYPE}_INITIAL ${CMAKE_${LANGUAGE}_FLAGS_${BUILD_TYPE}} CACHE STRING "")
set(CMAKE_${LANGUAGE}_FLAGS_${BUILD_TYPE} ${_CMAKE_${LANGUAGE}_FLAGS_${BUILD_TYPE}_INITIAL})
endforeach()
endforeach()
if(NOT MSVC)
# NEON optimizations in libpng17 seem to cause PNG load errors, see #14485.
add_definitions(-DPNG_ARM_NEON_OPT=0)
if(ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
endif()
if(CLANG)
add_definitions(-Wno-nullability-completeness)
add_definitions(-Wno-tautological-pointer-compare)
add_definitions(-Wno-deprecated-register)
endif()
if(USE_ASAN)
message("Address sanitizer enabled (DEBUG only)")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
add_definitions(-DUSE_ASAN)
endif()
if(USE_UBSAN)
message("Undefined behaviour sanitizer enabled (DEBUG only)")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=undefined")
# UBSAN is a collection of sanitizers, including vtpr, which reqiuires RTTI.
# ext/glslang disables RTTI by default using the `ENABLE_RTTI` option.
# If RTTI is disabled, we must also disable the vtpr sanitizer.
if(NOT ENABLE_RTTI)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-sanitize=vptr")
endif()
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -D_NDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -D_NDEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -D_NDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O2 -g -D_NDEBUG")
# Enable checking printf-like format strings (also works for logging functions)
add_definitions(-Wformat)
# Disable some warnings
add_definitions(-Wno-multichar)
# Don't compile with strict aliasing, we're not 100% aliasing-safe
add_compile_options(-fno-strict-aliasing)
if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -parallel -fopenmp")
endif()
if(X86 OR X86_64)
# enable sse2 code generation
add_definitions(-msse2)
endif()
if(IOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
elseif(APPLE AND NOT CMAKE_CROSSCOMPILING)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -U__STRICT_ANSI__")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
elseif(NOT ANDROID)
# TODO: See if we can get rid of no-psabi
if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_definitions(-Wno-psabi)
endif()
add_definitions(-D_XOPEN_SOURCE=700)
add_definitions(-D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1)
add_definitions(-D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64)
elseif(ANDROID)
add_definitions(-fsigned-char)
endif()
else()
# Disable warnings about MS-specific _s variants of libc functions
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if (NOT CLANG)
add_compile_options(-MP)
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_NDEBUG")
endif()
if(WIN32)
add_definitions(-D_UNICODE -DUNICODE)
add_definitions(-DUSING_WIN_UI)
endif()
if(NOT ANDROID)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
endif()
# This sets up the MSVC project dirs according to the physical project dirs
macro(setup_target_project TargetName ProjectDir)
get_property(TargetSources TARGET "${TargetName}" PROPERTY SOURCES)
foreach(Source ${TargetSources})
# Figure out the file's path relative to the ProjectDir
# NOTE: &#$@ double-quoted regexps
string(REGEX REPLACE "${ProjectDir}" "" RelativePath "${Source}")
string(REGEX REPLACE "[\\\\/][^\\\\/]*$" "" RelativePath "${RelativePath}")
string(REGEX REPLACE "^[\\\\/]" "" RelativePath "${RelativePath}")
string(REGEX REPLACE "/" "\\\\\\\\" RelativePath "${RelativePath}")
# put the source file in a source_group equivalent to the relative path
source_group("${RelativePath}" FILES ${Source})
endforeach()
endmacro()
add_subdirectory(ext)
if(WIN32)
include_directories(dx9sdk/Include)
include_directories(dx9sdk/Include/DX11)
endif()
set(CommonJIT
Core/MIPS/JitCommon/JitCommon.cpp
Core/MIPS/JitCommon/JitCommon.h
Core/MIPS/JitCommon/JitBlockCache.cpp
Core/MIPS/JitCommon/JitBlockCache.h
Core/MIPS/JitCommon/JitState.cpp
Core/MIPS/JitCommon/JitState.h
)
set(CommonX86
Common/ABI.cpp
Common/ABI.h
Common/CPUDetect.cpp
Common/CPUDetect.h
Common/Thunk.cpp
Common/Thunk.h
Common/x64Analyzer.cpp
Common/x64Analyzer.h
Common/x64Emitter.cpp
Common/x64Emitter.h
)
source_group(x86 FILES ${CommonX86})
set(CommonARM
Common/ArmCPUDetect.cpp
Common/ArmEmitter.h
Common/ArmEmitter.cpp
)
source_group(ARM FILES ${CommonARM})
set(CommonARM64
Common/Arm64Emitter.h
Common/Arm64Emitter.cpp
Common/ArmEmitter.h
Common/ArmEmitter.cpp
Core/Util/DisArm64.cpp
)
source_group(ARM64 FILES ${CommonARM64})
set(CommonMIPS
Common/MipsCPUDetect.cpp
Common/MipsEmitter.cpp
Common/MipsEmitter.h
)
source_group(MIPS FILES ${CommonMIPS})
set(CommonRISCV64
${CommonJIT}
Common/RiscVCPUDetect.cpp
Common/RiscVEmitter.cpp
Common/RiscVEmitter.h
Core/MIPS/fake/FakeJit.cpp
Core/MIPS/fake/FakeJit.h
)
source_group(RISCV64 FILES ${CommonRISCV64})
if(WIN32)
set(CommonD3D
Common/GPU/D3D9/D3D9ShaderCompiler.cpp
Common/GPU/D3D9/D3D9ShaderCompiler.h
Common/GPU/D3D9/D3D9StateCache.cpp
Common/GPU/D3D9/D3D9StateCache.h
Common/GPU/D3D9/thin3d_d3d9.cpp
Common/GPU/D3D9/D3DCompilerLoader.cpp
Common/GPU/D3D11/thin3d_d3d11.cpp
Common/GPU/D3D11/D3D11Loader.cpp
Common/GPU/D3D11/D3D11Loader.h
)
endif()
set(CommonVR
Common/VR/OpenXRLoader.cpp
Common/VR/OpenXRLoader.h
Common/VR/PPSSPPVR.cpp
Common/VR/PPSSPPVR.h
Common/VR/VRBase.cpp
Common/VR/VRBase.h
Common/VR/VRFramebuffer.cpp
Common/VR/VRFramebuffer.h
Common/VR/VRInput.cpp
Common/VR/VRInput.h
Common/VR/VRMath.cpp
Common/VR/VRMath.h
Common/VR/VRRenderer.cpp
Common/VR/VRRenderer.h
)
include_directories(ext/openxr)
add_library(Common STATIC
${CommonX86}
${CommonARM}
${CommonARM64}
${CommonMIPS}
${CommonRISCV64}
${CommonD3D}
${CommonVR}
Common/Serialize/Serializer.cpp
Common/Serialize/Serializer.h
Common/Serialize/SerializeDeque.h
Common/Serialize/SerializeFuncs.h
Common/Serialize/SerializeList.h
Common/Serialize/SerializeMap.h
Common/Serialize/SerializeSet.h
Common/Crypto/md5.cpp
Common/Crypto/md5.h
Common/Crypto/sha1.cpp
Common/Crypto/sha1.h
Common/Crypto/sha256.cpp
Common/Crypto/sha256.h
Common/Data/Collections/ConstMap.h
Common/Data/Collections/FixedSizeQueue.h
Common/Data/Collections/Hashmaps.h
Common/Data/Collections/TinySet.h
Common/Data/Collections/ThreadSafeList.h
Common/Data/Color/RGBAUtil.cpp
Common/Data/Color/RGBAUtil.h
Common/Data/Convert/ColorConv.cpp
Common/Data/Convert/ColorConv.h
Common/Data/Convert/SmallDataConvert.cpp
Common/Data/Convert/SmallDataConvert.h
Common/Data/Encoding/Base64.cpp
Common/Data/Encoding/Base64.h
Common/Data/Encoding/Compression.cpp
Common/Data/Encoding/Compression.h
Common/Data/Encoding/Shiftjis.h
Common/Data/Encoding/Utf8.cpp
Common/Data/Encoding/Utf8.h
Common/Data/Encoding/Utf16.h
Common/Data/Format/RIFF.cpp
Common/Data/Format/RIFF.h
Common/Data/Format/IniFile.cpp
Common/Data/Format/IniFile.h
Common/Data/Format/JSONReader.h
Common/Data/Format/JSONReader.cpp
Common/Data/Format/JSONWriter.h
Common/Data/Format/JSONWriter.cpp
Common/Data/Format/PNGLoad.cpp
Common/Data/Format/PNGLoad.h
Common/Data/Format/ZIMLoad.cpp
Common/Data/Format/ZIMLoad.h
Common/Data/Format/ZIMSave.cpp
Common/Data/Format/ZIMSave.h
Common/Data/Hash/Hash.cpp
Common/Data/Hash/Hash.h
Common/Data/Text/I18n.cpp
Common/Data/Text/I18n.h
Common/Data/Text/Parsers.cpp
Common/Data/Text/Parsers.h
Common/Data/Text/WrapText.cpp
Common/Data/Text/WrapText.h
Common/Data/Random/Rng.h
Common/File/VFS/VFS.h
Common/File/VFS/VFS.cpp
Common/File/VFS/AssetReader.cpp
Common/File/VFS/AssetReader.h
Common/File/AndroidStorage.h
Common/File/AndroidStorage.cpp
Common/File/DiskFree.h
Common/File/DiskFree.cpp
Common/File/Path.h
Common/File/Path.cpp
Common/File/PathBrowser.h
Common/File/PathBrowser.cpp
Common/File/FileUtil.cpp
Common/File/FileUtil.h
Common/File/DirListing.cpp
Common/File/DirListing.h
Common/File/FileDescriptor.cpp
Common/File/FileDescriptor.h
Common/GPU/DataFormat.h
Common/GPU/MiscTypes.h
Common/GPU/thin3d.cpp
Common/GPU/thin3d.h
Common/GPU/thin3d_create.h
Common/GPU/Shader.cpp
Common/GPU/Shader.h
Common/GPU/ShaderWriter.cpp
Common/GPU/ShaderWriter.h
Common/GPU/ShaderTranslation.h
Common/GPU/ShaderTranslation.cpp
Common/GPU/OpenGL/GLCommon.h
Common/GPU/OpenGL/GLDebugLog.cpp
Common/GPU/OpenGL/GLDebugLog.h
Common/GPU/OpenGL/GLSLProgram.cpp
Common/GPU/OpenGL/GLSLProgram.h
Common/GPU/OpenGL/gl3stub.c
Common/GPU/OpenGL/gl3stub.h
Common/GPU/OpenGL/GLFeatures.cpp
Common/GPU/OpenGL/GLFeatures.h
Common/GPU/OpenGL/thin3d_gl.cpp
Common/GPU/OpenGL/GLRenderManager.cpp
Common/GPU/OpenGL/GLRenderManager.h
Common/GPU/OpenGL/GLQueueRunner.cpp
Common/GPU/OpenGL/GLQueueRunner.h
Common/GPU/OpenGL/DataFormatGL.cpp
Common/GPU/OpenGL/DataFormatGL.h
Common/GPU/Vulkan/VulkanBarrier.cpp
Common/GPU/Vulkan/VulkanBarrier.h
Common/GPU/Vulkan/VulkanDebug.cpp
Common/GPU/Vulkan/VulkanDebug.h
Common/GPU/Vulkan/VulkanContext.cpp
Common/GPU/Vulkan/VulkanContext.h
Common/GPU/Vulkan/VulkanFramebuffer.cpp
Common/GPU/Vulkan/VulkanFramebuffer.h
Common/GPU/Vulkan/VulkanImage.cpp
Common/GPU/Vulkan/VulkanImage.h
Common/GPU/Vulkan/VulkanLoader.cpp
Common/GPU/Vulkan/VulkanLoader.h
Common/GPU/Vulkan/VulkanMemory.cpp
Common/GPU/Vulkan/VulkanMemory.h
Common/GPU/Vulkan/VulkanProfiler.cpp
Common/GPU/Vulkan/VulkanProfiler.h
Common/GPU/Vulkan/thin3d_vulkan.cpp
Common/GPU/Vulkan/VulkanRenderManager.cpp
Common/GPU/Vulkan/VulkanRenderManager.h
Common/GPU/Vulkan/VulkanQueueRunner.cpp
Common/GPU/Vulkan/VulkanQueueRunner.h
Common/GPU/Vulkan/VulkanFrameData.cpp
Common/GPU/Vulkan/VulkanFrameData.h
Common/Input/GestureDetector.cpp
Common/Input/GestureDetector.h
Common/Input/KeyCodes.h
Common/Input/InputState.cpp
Common/Input/InputState.h
Common/Math/fast/fast_matrix.c
Common/Math/curves.cpp
Common/Math/curves.h
Common/Math/expression_parser.cpp
Common/Math/expression_parser.h
Common/Math/lin/matrix4x4.cpp
Common/Math/lin/matrix4x4.h
Common/Math/lin/vec3.cpp
Common/Math/lin/vec3.h
Common/Math/math_util.cpp
Common/Math/math_util.h
Common/Math/Statistics.h
Common/Math/Statistics.cpp
Common/Net/HTTPClient.cpp
Common/Net/HTTPClient.h
Common/Net/HTTPHeaders.cpp
Common/Net/HTTPHeaders.h
Common/Net/HTTPServer.cpp
Common/Net/HTTPServer.h
Common/Net/NetBuffer.cpp
Common/Net/NetBuffer.h
Common/Net/Resolve.cpp
Common/Net/Resolve.h
Common/Net/Sinks.cpp
Common/Net/Sinks.h
Common/Net/URL.cpp
Common/Net/URL.h
Common/Net/WebsocketServer.cpp
Common/Net/WebsocketServer.h
Common/Profiler/Profiler.cpp
Common/Profiler/Profiler.h
Common/Render/TextureAtlas.cpp
Common/Render/TextureAtlas.h
Common/Render/DrawBuffer.cpp
Common/Render/DrawBuffer.h
Common/Render/ManagedTexture.cpp
Common/Render/ManagedTexture.h
Common/Render/Text/draw_text.cpp
Common/Render/Text/draw_text.h
Common/Render/Text/draw_text_android.cpp
Common/Render/Text/draw_text_android.h
Common/Render/Text/draw_text_win.cpp
Common/Render/Text/draw_text_win.h
Common/Render/Text/draw_text_uwp.cpp
Common/Render/Text/draw_text_uwp.h
Common/System/Display.cpp
Common/System/Display.h
Common/Thread/Channel.h
Common/Thread/ParallelLoop.cpp
Common/Thread/ParallelLoop.h
Common/Thread/Promise.h
Common/Thread/ThreadUtil.cpp
Common/Thread/ThreadUtil.h
Common/Thread/ThreadManager.cpp
Common/Thread/ThreadManager.h
Common/UI/AsyncImageFileView.cpp
Common/UI/AsyncImageFileView.h
Common/UI/Root.cpp
Common/UI/Root.h
Common/UI/Screen.cpp
Common/UI/Screen.h
Common/UI/UI.cpp
Common/UI/UI.h
Common/UI/Context.cpp
Common/UI/Context.h
Common/UI/UIScreen.cpp
Common/UI/UIScreen.h
Common/UI/Tween.cpp
Common/UI/Tween.h
Common/UI/View.cpp
Common/UI/View.h
Common/UI/ViewGroup.cpp
Common/UI/ViewGroup.h
Common/BitScan.h
Common/BitSet.h
Common/Buffer.h
Common/Buffer.cpp
Common/CodeBlock.h
Common/Common.h
Common/CommonFuncs.h
Common/CommonTypes.h
Common/ConsoleListener.cpp
Common/ConsoleListener.h
Common/DbgNew.h
Common/FakeEmitter.h
Common/FakeCPUDetect.cpp
Common/ExceptionHandlerSetup.cpp
Common/ExceptionHandlerSetup.h
Common/Log.h
Common/Log.cpp
Common/LogManager.cpp
Common/LogManager.h
Common/LogReporting.cpp
Common/LogReporting.h
Common/MemArenaAndroid.cpp
Common/MemArenaDarwin.cpp
Common/MemArenaPosix.cpp
Common/MemArenaWin32.cpp
Common/MemArena.h
Common/MemoryUtil.cpp
Common/MemoryUtil.h
Common/OSVersion.cpp
Common/OSVersion.h
Common/StringUtils.cpp
Common/StringUtils.h
Common/SysError.h
Common/SysError.cpp
Common/TimeUtil.cpp
Common/TimeUtil.h
)
include_directories(Common)
setup_target_project(Common Common)
target_link_libraries(Common Ext::Snappy)
if(USING_GLES2 OR (USING_EGL AND NOT USING_FBDEV))
find_package(X11)
endif()
add_library(gason STATIC
ext/gason/gason.cpp
ext/gason/gason.h
)
add_library(vma STATIC
ext/vma/vk_mem_alloc.cpp
ext/vma/vk_mem_alloc.h
)
if(USE_FFMPEG)
if(NOT FFMPEG_DIR)
if(NOT USE_SYSTEM_FFMPEG)
if(ANDROID)
if(ARMV7)
set(PLATFORM_ARCH "android/armv7")
elseif(ARM64)
set(PLATFORM_ARCH "android/arm64")
elseif(X86_64)
set(PLATFORM_ARCH "android/x86_64")
elseif(X86)
set(PLATFORM_ARCH "android/x86")
endif()
elseif(IOS)
set(PLATFORM_ARCH "ios/universal")
elseif(MACOSX)
set(PLATFORM_ARCH "macosx/universal")
elseif(LINUX)
if(ARMV7)
set(PLATFORM_ARCH "linux/armv7")
elseif(ARM64)
set(PLATFORM_ARCH "linux/aarch64")
elseif(ARM)
set(PLATFORM_ARCH "linux/arm")
elseif(MIPS)
set(PLATFORM_ARCH "linux/mips32")
elseif(RISCV64)
set(PLATFORM_ARCH "linux/riscv64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATFORM_ARCH "linux/x86_64")
elseif(X86)
set(PLATFORM_ARCH "linux/x86")
endif()
elseif(WIN32)
if(X86_64)
set(PLATFORM_ARCH "Windows/x86_64")
elseif(X86)
set(PLATFORM_ARCH "Windows/x86")
endif()
endif()
if(PLATFORM_ARCH)
set(FFMPEG_DIR "ffmpeg/${PLATFORM_ARCH}")
else()
message("Couldn't find an internal FFmpeg build, using system FFmpeg instead")
endif()
endif()
endif()
find_package(FFmpeg REQUIRED avcodec avformat avutil swresample swscale)
endif(USE_FFMPEG)
find_package(ZLIB)
if(ZLIB_FOUND AND NOT ANDROID)
include_directories(${ZLIB_INCLUDE_DIR})
add_definitions(-DSHARED_ZLIB)
else()
add_library(zlib STATIC
ext/zlib/adler32.c
ext/zlib/compress.c
ext/zlib/crc32.c
ext/zlib/crc32.h
ext/zlib/deflate.c
ext/zlib/deflate.h
ext/zlib/gzclose.c
ext/zlib/gzguts.h
ext/zlib/gzlib.c
ext/zlib/gzread.c
ext/zlib/gzwrite.c
ext/zlib/infback.c
ext/zlib/inffast.c
ext/zlib/inffast.h
ext/zlib/inffixed.h
ext/zlib/inflate.c
ext/zlib/inflate.h
ext/zlib/inftrees.c
ext/zlib/inftrees.h
ext/zlib/make_vms.com
ext/zlib/trees.c
ext/zlib/trees.h
ext/zlib/uncompr.c
ext/zlib/zconf.h
ext/zlib/zlib.h
ext/zlib/zutil.c
ext/zlib/zutil.h
)
include_directories(ext/zlib)
set(ZLIB_LIBRARY zlib)
endif()
add_library(cityhash STATIC
ext/cityhash/city.cpp
ext/cityhash/city.h
ext/cityhash/citycrc.h
)
target_include_directories(cityhash PRIVATE ext/cityhash)
if(NOT MSVC)
# These can be fast even for debug.
set_target_properties(udis86 PROPERTIES COMPILE_FLAGS "-O2")
set_target_properties(cityhash PROPERTIES COMPILE_FLAGS "-O2")
if(NOT ZLIB_FOUND)
set_target_properties(zlib PROPERTIES COMPILE_FLAGS "-O2")
endif()
endif()
find_package(LIBZIP)
if(LIBZIP_FOUND AND USE_SYSTEM_LIBZIP)
add_definitions(-DSHARED_LIBZIP)
else()
add_library(libzip STATIC
ext/libzip/zip_add.c
ext/libzip/zip_add_dir.c
ext/libzip/zip_add_entry.c
ext/libzip/zip_algorithm_deflate.c
ext/libzip/zip_buffer.c
ext/libzip/zip_close.c
ext/libzip/zip_delete.c
ext/libzip/zip_dir_add.c
ext/libzip/zip_dirent.c
ext/libzip/zip_discard.c
ext/libzip/zip_entry.c
ext/libzip/zip_error.c
ext/libzip/zip_error_clear.c
ext/libzip/zip_error_get.c
ext/libzip/zip_error_get_sys_type.c
ext/libzip/zip_error_strerror.c
ext/libzip/zip_error_to_str.c
ext/libzip/zip_extra_field.c
ext/libzip/zip_extra_field_api.c
ext/libzip/zip_fclose.c
ext/libzip/zip_fdopen.c
ext/libzip/zip_file_add.c
ext/libzip/zip_file_error_clear.c
ext/libzip/zip_file_error_get.c
ext/libzip/zip_file_get_comment.c
ext/libzip/zip_file_get_external_attributes.c
ext/libzip/zip_file_get_offset.c
ext/libzip/zip_file_rename.c
ext/libzip/zip_file_replace.c
ext/libzip/zip_file_set_comment.c
ext/libzip/zip_file_set_encryption.c
ext/libzip/zip_file_set_external_attributes.c
ext/libzip/zip_file_set_mtime.c
ext/libzip/zip_file_strerror.c
ext/libzip/zip_fopen.c
ext/libzip/zip_fopen_encrypted.c
ext/libzip/zip_fopen_index.c
ext/libzip/zip_fopen_index_encrypted.c
ext/libzip/zip_fread.c
ext/libzip/zip_fseek.c
ext/libzip/zip_ftell.c
ext/libzip/zip_get_archive_comment.c
ext/libzip/zip_get_archive_flag.c
ext/libzip/zip_get_encryption_implementation.c
ext/libzip/zip_get_file_comment.c
ext/libzip/zip_get_name.c
ext/libzip/zip_get_num_entries.c
ext/libzip/zip_get_num_files.c
ext/libzip/zip_hash.c
ext/libzip/zip_io_util.c
ext/libzip/zip_libzip_version.c
ext/libzip/zip_memdup.c
ext/libzip/zip_name_locate.c
ext/libzip/zip_new.c
ext/libzip/zip_open.c
ext/libzip/zip_pkware.c
ext/libzip/zip_progress.c
ext/libzip/zip_rename.c
ext/libzip/zip_replace.c
ext/libzip/zip_set_archive_comment.c
ext/libzip/zip_set_archive_flag.c
ext/libzip/zip_set_default_password.c
ext/libzip/zip_set_file_comment.c
ext/libzip/zip_set_file_compression.c
ext/libzip/zip_set_name.c
ext/libzip/zip_source_accept_empty.c
ext/libzip/zip_source_begin_write.c
ext/libzip/zip_source_begin_write_cloning.c
ext/libzip/zip_source_buffer.c
ext/libzip/zip_source_call.c
ext/libzip/zip_source_close.c
ext/libzip/zip_source_commit_write.c
ext/libzip/zip_source_compress.c
ext/libzip/zip_source_crc.c
ext/libzip/zip_source_error.c
ext/libzip/zip_source_file_common.c
ext/libzip/zip_source_file_stdio.c
ext/libzip/zip_source_free.c
ext/libzip/zip_source_function.c
ext/libzip/zip_source_get_file_attributes.c
ext/libzip/zip_source_is_deleted.c
ext/libzip/zip_source_layered.c
ext/libzip/zip_source_open.c
ext/libzip/zip_source_pkware_decode.c
ext/libzip/zip_source_pkware_encode.c
ext/libzip/zip_source_read.c
ext/libzip/zip_source_remove.c
ext/libzip/zip_source_rollback_write.c
ext/libzip/zip_source_seek.c
ext/libzip/zip_source_seek_write.c
ext/libzip/zip_source_stat.c
ext/libzip/zip_source_supports.c
ext/libzip/zip_source_tell.c
ext/libzip/zip_source_tell_write.c
ext/libzip/zip_source_window.c
ext/libzip/zip_source_write.c