forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1882 lines (1767 loc) · 52.7 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.6)
project(PPSSPP)
#This is supposed to work but doesn't!
if (NOT ANDROID)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
enable_language(ASM)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
add_definitions(-D__STDC_CONSTANT_MACROS)
# Of the CMake platforms, we only support Vulkan on Android and Windows.
if(ANDROID OR WIN32)
set(VULKAN ON)
else()
add_definitions(-DNO_VULKAN)
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CLANG ON)
message("Clang enabled")
endif()
# Detect CPU from CMAKE configuration. Toolchains should set this up
if(CMAKE_SYSTEM_PROCESSOR)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
set(ARM ON)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^armv7")
set(ARMV7 ON)
# 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 "^aarch64")
set(ARM64 ON)
add_definitions(-DARM64)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^amd64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "^AMD64")
set(X86 ON)
set(X86_64 ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
set(X86 ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^mips")
set(MIPS ON)
else()
message("Unknown CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
endif()
include(ccache)
# Remove soon?
set(USE_FFMPEG ON)
if(NOT ANDROID)
if(ARM OR SIMULATOR)
set(USING_EGL ON)
endif()
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX ON)
add_definitions(-D__STDC_CONSTANT_MACROS)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX ON)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(ANDROID ON)
endif()
if(NOT DEFINED HEADLESS)
set(HEADLESS OFF)
endif()
if(GOLD)
add_definitions(-DGOLD)
message("Gold Build")
else()
message("Normal Build")
endif()
# Doesn't link on some platforms
#if(NOT DEFINED UNITTEST)
# set(UNITTEST OFF)
#endif()
# User-editable options (go into CMakeCache.txt)
# :: Processors
option(ARMV7 "Set to ON if targeting an ARMv7 processor" ${ARMV7})
option(ARM "Set to ON if targeting an ARM processor" ${ARM})
option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS})
option(X86 "Set to ON if targeting an X86 processor" ${X86})
option(X86_64 "Set to ON if targeting an X86_64 processor" ${X86_64})
# :: 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(RASPBIAN "Set to ON to workaround threading issues when building for ARMV7 on Raspbian" ${RASPBIAN})
# :: 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})
# :: Options
option(USE_FFMPEG "Build with FFMPEG support" ${USE_FFMPEG})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
if(ANDROID)
set(CoreLibName ppsspp_jni)
set(CoreLinkType SHARED)
set(MOBILE_DEVICE ON)
set(USING_GLES2 ON)
else()
set(CoreLibName Core)
set(CoreLinkType STATIC)
endif()
include_directories(ext/native)
if(NOT OPENGL_LIBRARIES AND USING_GLES2)
set(OPENGL_LIBRARIES GLESv2)
endif()
if(NOT OPENGL_LIBRARIES)
find_package(OpenGL REQUIRED)
endif()
find_package(SDL2)
include(FindThreads)
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
endif()
include_directories("${CMAKE_SOURCE_DIR}")
if(USING_EGL)
add_definitions(-DUSING_EGL)
endif()
if(USING_FBDEV)
add_definitions(-DUSING_FBDEV)
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(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()
if(NOT MSVC)
if (ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-uninitialized")
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} -O3 -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} -O3 -D_NDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O2 -g -D_NDEBUG")
#TODO: Remove this and include the file properly everywhere it makes sense
# First step is too use the macros everywhere
# Second step is to remove the compatibility defines
# Third step is to include the file
# Fourth step is to remove that line!
add_compile_options(-include ${CMAKE_CURRENT_SOURCE_DIR}/ppsspp_config.h)
# Disable some warnings
add_definitions(-Wno-multichar)
add_definitions(-Wno-deprecated-register)
# Don't compile with strict aliasing, we're not 100% aliasing-safe
add_definitions(-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)
elseif(APPLE AND NOT CMAKE_CROSSCOMPILING)
# We want C++11, so target 10.7+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -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} STREQUAL "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)
add_definitions(-D_UNICODE -DUNICODE)
add_definitions(-DUSING_WIN_UI)
add_definitions(-MP)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_NDEBUG")
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()
# Commented-out files are files that don't compile
# and were disabled in the original MSVC project anyway
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
Common/ColorConvNEON.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})
if(NOT (X86 OR ARM OR MIPS))
set(CommonFake
Common/FakeCPUDetect.cpp
Common/FakeEmitter.h)
source_group(Fake FILES ${CommonFake})
endif()
set(CommonWindows
Common/stdafx.cpp
Common/stdafx.h)
source_group(Windows FILES ${CommonWindows})
if(VULKAN)
set(CommonVulkan ${CommonExtra}
Common/Vulkan/SPIRVDisasm.cpp
Common/Vulkan/SPIRVDisasm.h
Common/Vulkan/VulkanContext.cpp
Common/Vulkan/VulkanContext.h
Common/Vulkan/VulkanImage.cpp
Common/Vulkan/VulkanImage.h
Common/Vulkan/VulkanLoader.cpp
Common/Vulkan/VulkanLoader.h
Common/Vulkan/VulkanMemory.cpp
Common/Vulkan/VulkanMemory.h)
else()
set(CommonVulkan)
endif()
add_library(Common STATIC
${CommonX86}
${CommonARM}
${CommonARM64}
${CommonMIPS}
${CommonFake}
${CommonWindows}
${CommonVulkan}
Common/ColorConv.cpp
Common/ColorConv.h
Common/ChunkFile.cpp
Common/ChunkFile.h
Common/ConsoleListener.cpp
Common/ConsoleListener.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/FileUtil.cpp
Common/FileUtil.h
Common/KeyMap.cpp
Common/KeyMap.h
Common/LogManager.cpp
Common/Hashmaps.h
Common/LogManager.h
Common/MemArenaAndroid.cpp
Common/MemArenaDarwin.cpp
Common/MemArenaPosix.cpp
Common/MemArenaWin32.cpp
Common/MemArena.h
Common/MemoryUtil.cpp
Common/MemoryUtil.h
Common/Misc.cpp
Common/MsgHandler.cpp
Common/MsgHandler.h
Common/OSVersion.cpp
Common/OSVersion.h
Common/StringUtils.cpp
Common/StringUtils.h
Common/ThreadPools.cpp
Common/ThreadPools.h
Common/ThreadSafeList.h
Common/Timer.cpp
Common/Timer.h)
add_subdirectory(ext)
include_directories(Common)
setup_target_project(Common Common)
target_link_libraries(Common Ext::Snappy)
if(WIN32)
include_directories(dx9sdk/Include)
target_link_libraries(Common winmm d3d9 dxguid dsound)
endif()
if(TARGET SDL2::SDL2)
target_link_libraries(Common SDL2::SDL2)
endif()
if(USING_GLES2)
find_package(X11)
endif()
add_library(vjson STATIC
ext/native/ext/vjson/json.cpp
ext/native/ext/vjson/json.h
ext/native/ext/vjson/block_allocator.cpp
ext/native/ext/vjson/block_allocator.h
)
add_library(rg_etc1 STATIC
ext/native/ext/rg_etc1/rg_etc1.cpp
ext/native/ext/rg_etc1/rg_etc1.h)
include_directories(ext/native/ext/rg_etc1)
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/x86_64")
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(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/native/ext/cityhash/city.cpp
ext/native/ext/cityhash/city.h
ext/native/ext/cityhash/citycrc.h
)
include_directories(ext/cityhash)
if (NOT MSVC)
# These can be fast even for debug.
set_target_properties(udis86 PROPERTIES COMPILE_FLAGS "-O3")
set_target_properties(cityhash PROPERTIES COMPILE_FLAGS "-O3")
if(NOT ZLIB_FOUND)
set_target_properties(zlib PROPERTIES COMPILE_FLAGS "-O3")
endif()
endif()
find_package(LibZip)
if(LIBZIP_FOUND)
add_definitions(-DSHARED_LIBZIP)
else()
add_library(libzip STATIC
ext/native/ext/libzip/zip.h
ext/native/ext/libzip/mkstemp.c
ext/native/ext/libzip/zip_add.c
ext/native/ext/libzip/zip_add_dir.c
ext/native/ext/libzip/zip_close.c
ext/native/ext/libzip/zip_delete.c
ext/native/ext/libzip/zip_dirent.c
ext/native/ext/libzip/zip_entry_free.c
ext/native/ext/libzip/zip_entry_new.c
ext/native/ext/libzip/zip_err_str.c
ext/native/ext/libzip/zip_error.c
ext/native/ext/libzip/zip_error_clear.c
ext/native/ext/libzip/zip_error_get.c
ext/native/ext/libzip/zip_error_get_sys_type.c
ext/native/ext/libzip/zip_error_strerror.c
ext/native/ext/libzip/zip_error_to_str.c
ext/native/ext/libzip/zip_fclose.c
ext/native/ext/libzip/zip_file_error_clear.c
ext/native/ext/libzip/zip_file_error_get.c
ext/native/ext/libzip/zip_file_get_offset.c
ext/native/ext/libzip/zip_file_strerror.c
ext/native/ext/libzip/zip_filerange_crc.c
ext/native/ext/libzip/zip_fopen.c
ext/native/ext/libzip/zip_fopen_index.c
ext/native/ext/libzip/zip_fread.c
ext/native/ext/libzip/zip_free.c
ext/native/ext/libzip/zip_get_archive_comment.c
ext/native/ext/libzip/zip_get_archive_flag.c
ext/native/ext/libzip/zip_get_file_comment.c
ext/native/ext/libzip/zip_get_name.c
ext/native/ext/libzip/zip_get_num_files.c
ext/native/ext/libzip/zip_memdup.c
ext/native/ext/libzip/zip_name_locate.c
ext/native/ext/libzip/zip_new.c
ext/native/ext/libzip/zip_open.c
ext/native/ext/libzip/zip_rename.c
ext/native/ext/libzip/zip_replace.c
ext/native/ext/libzip/zip_set_archive_comment.c
ext/native/ext/libzip/zip_set_archive_flag.c
ext/native/ext/libzip/zip_set_file_comment.c
ext/native/ext/libzip/zip_set_name.c
ext/native/ext/libzip/zip_source_buffer.c
ext/native/ext/libzip/zip_source_file.c
ext/native/ext/libzip/zip_source_filep.c
ext/native/ext/libzip/zip_source_free.c
ext/native/ext/libzip/zip_source_function.c
ext/native/ext/libzip/zip_source_zip.c
ext/native/ext/libzip/zip_stat.c
ext/native/ext/libzip/zip_stat_index.c
ext/native/ext/libzip/zip_stat_init.c
ext/native/ext/libzip/zip_strerror.c
ext/native/ext/libzip/zip_unchange.c
ext/native/ext/libzip/zip_unchange_all.c
ext/native/ext/libzip/zip_unchange_archive.c
ext/native/ext/libzip/zip_unchange_data.c)
target_link_libraries(libzip)
include_directories(ext/native/ext/libzip)
set(LIBZIP_LIBRARY libzip)
endif()
# FindPNG does a few things we don't want. So do it ourselves. Fixed to libpng17
find_path(PNG_PNG_INCLUDE_DIR NAMES "libpng17/png.h")
find_library(PNG_LIBRARY NAMES png17 libpng17)
find_package(PackageHandleStandardArgs)
find_package_handle_standard_args(PNG REQUIRED_VARS PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
if (PNG_FOUND)
include_directories(${PNG_PNG_INCLUDE_DIR})
else()
if(ARM)
set(PNG_ARM_INCLUDES
ext/native/ext/libpng17/arm/arm_init.c
ext/native/ext/libpng17/arm/filter_neon.S
ext/native/ext/libpng17/arm/filter_neon_intrinsics.c
)
endif()
add_library(png17 STATIC
ext/native/ext/libpng17/pngconf.h
ext/native/ext/libpng17/pngdebug.h
ext/native/ext/libpng17/png.c
ext/native/ext/libpng17/png.h
ext/native/ext/libpng17/pngerror.c
ext/native/ext/libpng17/pngget.c
ext/native/ext/libpng17/pnginfo.h
ext/native/ext/libpng17/pnglibconf.h
ext/native/ext/libpng17/pngmem.c
ext/native/ext/libpng17/pngpread.c
ext/native/ext/libpng17/pngpriv.h
ext/native/ext/libpng17/pngread.c
ext/native/ext/libpng17/pngrio.c
ext/native/ext/libpng17/pngrtran.c
ext/native/ext/libpng17/pngrutil.c
ext/native/ext/libpng17/pngset.c
ext/native/ext/libpng17/pngstruct.h
ext/native/ext/libpng17/pngtrans.c
ext/native/ext/libpng17/pngwio.c
ext/native/ext/libpng17/pngwrite.c
ext/native/ext/libpng17/pngwtran.c
ext/native/ext/libpng17/pngwutil.c
${PNG_ARM_INCLUDES} )
set(PNG_LIBRARY png17)
include_directories(ext/native/ext)
endif()
set(nativeExtra)
set(nativeExtraLibs)
if(ANDROID)
set(nativeExtra ${nativeExtra}
Common/GL/GLInterface/EGLAndroid.cpp
Common/GL/GLInterface/EGLAndroid.h
Common/GL/GLInterface/EGL.cpp
Common/GL/GLInterface/EGL.h
Common/GL/GLInterface/GLInterface.cpp
Common/GL/GLInterfaceBase.h)
set(nativeExtra ${nativeExtra}
ext/native/base/NativeApp.h
android/jni/app-android.cpp
android/jni/native_audio.cpp
android/jni/native_audio.h
android/jni/native-audio-so.cpp
android/jni/native-audio-so.h)
# No target
elseif(IOS)
set(nativeExtra ${nativeExtra}
ios/main.mm
ios/AppDelegate.mm
ios/AppDelegate.h
ios/ViewController.mm
ios/ViewController.h
ios/iOSCoreAudio.cpp
ios/iOSCoreAudio.h
ios/PPSSPPUIApplication.h
ios/PPSSPPUIApplication.mm
ios/SmartKeyboardMap.cpp
ios/SmartKeyboardMap.hpp
ios/iCade/iCadeReaderView.h
ios/iCade/iCadeReaderView.m
ios/iCade/iCadeState.h)
set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit -framework GLKit -framework OpenAL")
if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework")
set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController")
endif()
if(NOT ICONV_LIBRARY)
set(nativeExtraLibs ${nativeExtraLibs} iconv)
endif()
set_source_files_properties(ios/AppDelegate.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
set_source_files_properties(ios/ViewController.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
set(TargetBin PPSSPP)
elseif(USING_QT_UI)
set(CMAKE_AUTOMOC ON)
find_package(Qt5 COMPONENTS OpenGL Gui Core)
if(NOT SDL2_FOUND)
find_package(Qt5 COMPONENTS Multimedia)
endif(NOT SDL2_FOUND)
set(Qt_UI
Qt/Debugger/debugger_disasm.ui
Qt/Debugger/debugger_displaylist.ui
Qt/Debugger/debugger_memory.ui
Qt/Debugger/debugger_memorytex.ui
Qt/Debugger/debugger_vfpu.ui
)
qt5_wrap_ui(QT_UI_GEN ${Qt_UI})
list(APPEND NativeAppSource
${QT_UI_GEN}
ext/native/base/QtMain.cpp
ext/native/base/QtMain.h
Qt/mainwindow.cpp
Qt/mainwindow.h
Qt/Debugger/ctrldisasmview.cpp
Qt/Debugger/ctrldisasmview.h
Qt/Debugger/ctrlmemview.cpp
Qt/Debugger/ctrlmemview.h
Qt/Debugger/ctrlregisterlist.cpp
Qt/Debugger/ctrlregisterlist.h
Qt/Debugger/ctrlvfpuview.cpp
Qt/Debugger/ctrlvfpuview.h
Qt/Debugger/debugger_disasm.cpp
Qt/Debugger/debugger_disasm.h
Qt/Debugger/debugger_displaylist.cpp
Qt/Debugger/debugger_displaylist.h
Qt/Debugger/debugger_memory.cpp
Qt/Debugger/debugger_memory.h
Qt/Debugger/debugger_memorytex.cpp
Qt/Debugger/debugger_memorytex.h
Qt/Debugger/debugger_vfpu.cpp
Qt/Debugger/debugger_vfpu.h
)
add_definitions(-DUSING_QT_UI)
include_directories(${CMAKE_CURRENT_BINARY_DIR} Qt Qt/Debugger)
set(nativeExtraLibs ${nativeExtraLibs} Qt5::OpenGL Qt5::Gui Qt5::Core)
set(TargetBin PPSSPPQt)
# Enable SDL if found
if (SDL2_FOUND)
add_definitions(-DSDL)
set(nativeExtra ${nativeExtra}
SDL/SDLJoystick.h
SDL/SDLJoystick.cpp)
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
else(SDL2_FOUND)
set(nativeExtraLibs ${nativeExtraLibs} Qt5::Multimedia)
endif()
elseif(TARGET SDL2::SDL2)
set(TargetBin PPSSPPSDL)
# Require SDL
add_definitions(-DSDL)
set(nativeExtra ${nativeExtra}
SDL/SDLJoystick.h
SDL/SDLJoystick.cpp
ext/native/base/PCMain.cpp)
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
if(APPLE)
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm)
set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY})
elseif(USING_EGL)
if(NOT EGL_LIBRARIES)
set(EGL_LIBRARIES EGL)
endif()
set(nativeExtraLibs ${nativeExtraLibs} pthread ${EGL_LIBRARIES})
endif()
set(TargetBin PPSSPPSDL)
elseif(WIN32)
# Don't care about SDL.
set(TargetBin PPSSPPWindows)
if(X86_64)
link_directories(dx9sdk/Lib/x64)
else()
link_directories(dx9sdk/Lib/x86)
endif()
else()
message(FATAL_ERROR "Could not find SDL2. Failing.")
endif()
list(APPEND NativeAppSource
android/jni/TestRunner.cpp
UI/NativeApp.cpp
UI/BackgroundAudio.cpp
UI/DevScreens.cpp
UI/DisplayLayoutEditor.cpp
UI/DisplayLayoutScreen.cpp
UI/EmuScreen.cpp
UI/GameInfoCache.cpp
UI/MainScreen.cpp
UI/MiscScreens.cpp
UI/PauseScreen.cpp
UI/GameScreen.cpp
UI/GameSettingsScreen.cpp
UI/TiltAnalogSettingsScreen.cpp
UI/TiltEventProcessor.cpp
UI/TouchControlLayoutScreen.cpp
UI/TouchControlVisibilityScreen.cpp
UI/GamepadEmu.cpp
UI/OnScreenDisplay.cpp
UI/ControlMappingScreen.cpp
UI/RemoteISOScreen.cpp
UI/ReportScreen.cpp
UI/SavedataScreen.cpp
UI/Store.cpp
UI/CwCheatScreen.cpp
UI/InstallZipScreen.cpp
UI/ProfilerDraw.cpp
UI/ui_atlas.cpp
UI/TextureUtil.cpp
UI/ComboKeyMappingScreen.cpp)
if(ANDROID)
if (ARM)
set(NativeAppSource ${NativeAppSource} android/jni/ArmEmitterTest.cpp)
elseif (ARM64)
set(NativeAppSource ${NativeAppSource} android/jni/Arm64EmitterTest.cpp)
endif()
set(nativeExtra ${nativeExtra} ${NativeAppSource})
endif()
set(THIN3D_PLATFORMS ext/native/thin3d/thin3d_gl.cpp)
if(VULKAN)
set(THIN3D_PLATFORMS ${THIN3D_PLATFORMS}
ext/native/thin3d/thin3d_vulkan.cpp
ext/native/thin3d/VulkanRenderManager.cpp
ext/native/thin3d/VulkanRenderManager.h
ext/native/thin3d/VulkanQueueRunner.cpp
ext/native/thin3d/VulkanQueueRunner.h
ext/native/thin3d/DataFormat.h)
endif()
if(WIN32)
set(THIN3D_PLATFORMS ${THIN3D_PLATFORMS}
ext/native/thin3d/thin3d_d3d9.cpp
ext/native/thin3d/thin3d_d3d11.cpp
ext/native/thin3d/d3dx9_loader.cpp
ext/native/thin3d/d3dx9_loader.h
ext/native/thin3d/d3d11_loader.cpp
ext/native/thin3d/d3d11_loader.h)
endif()
add_library(native STATIC
${nativeExtra}
ext/native/base/backtrace.cpp
ext/native/base/backtrace.h
ext/native/base/basictypes.h
ext/native/base/buffer.cpp
ext/native/base/buffer.h
ext/native/base/colorutil.cpp
ext/native/base/colorutil.h
ext/native/base/display.cpp
ext/native/base/display.h
ext/native/base/linked_ptr.h
ext/native/base/logging.h
ext/native/base/stringutil.cpp
ext/native/base/stringutil.h
ext/native/base/timeutil.cpp
ext/native/base/timeutil.h
ext/native/data/compression.cpp
ext/native/data/compression.h
ext/native/ext/vjson/json.cpp
ext/native/ext/vjson/json.h
ext/native/ext/vjson/block_allocator.cpp
ext/native/ext/vjson/block_allocator.h
ext/native/file/chunk_file.cpp
ext/native/file/chunk_file.h
ext/native/file/fd_util.cpp
ext/native/file/fd_util.h
ext/native/file/file_util.cpp
ext/native/file/file_util.h
ext/native/file/free.cpp
ext/native/file/free.h
ext/native/file/ini_file.cpp
ext/native/file/ini_file.h
ext/native/file/path.cpp
ext/native/file/path.h
ext/native/file/vfs.h
ext/native/file/zip_read.cpp
ext/native/file/zip_read.h
ext/native/gfx/GLStateCache.cpp
ext/native/gfx/GLStateCache.h
ext/native/gfx/gl_common.h
ext/native/gfx/gl_debug_log.cpp
ext/native/gfx/gl_debug_log.h
ext/native/gfx/gl_lost_manager.cpp
ext/native/gfx/gl_lost_manager.h
ext/native/gfx/texture_atlas.cpp
ext/native/gfx/texture_atlas.h
ext/native/gfx/d3d9_shader.cpp
ext/native/gfx/d3d9_shader.h
ext/native/gfx/d3d9_state.cpp
ext/native/gfx/d3d9_state.h
ext/native/gfx_es2/draw_buffer.cpp
ext/native/gfx_es2/draw_buffer.h
ext/native/gfx_es2/draw_text.cpp
ext/native/gfx_es2/draw_text.h
ext/native/gfx_es2/draw_text_win.cpp
ext/native/gfx_es2/draw_text_win.h
ext/native/gfx_es2/draw_text_qt.cpp
ext/native/gfx_es2/draw_text_qt.h
ext/native/gfx_es2/draw_text_android.cpp
ext/native/gfx_es2/draw_text_android.h
ext/native/gfx_es2/gpu_features.cpp
ext/native/gfx_es2/gpu_features.h
ext/native/gfx_es2/glsl_program.cpp
ext/native/gfx_es2/glsl_program.h
ext/native/gfx_es2/gl3stub.c
ext/native/gfx_es2/gl3stub.h
ext/native/i18n/i18n.cpp
ext/native/i18n/i18n.h
ext/native/image/png_load.cpp
ext/native/image/png_load.h
ext/native/image/zim_load.cpp
ext/native/image/zim_load.h
ext/native/image/zim_save.cpp
ext/native/image/zim_save.h
ext/native/input/gesture_detector.cpp
ext/native/input/gesture_detector.h
ext/native/input/keycodes.h
ext/native/input/input_state.h
ext/native/input/input_state.cpp
ext/native/math/fast/fast_math.c
ext/native/math/fast/fast_matrix.c
ext/native/math/fast/fast_matrix_neon.S
ext/native/math/fast/fast_matrix_sse.c
ext/native/math/dataconv.cpp
ext/native/math/dataconv.h
ext/native/math/curves.cpp
ext/native/math/curves.h
ext/native/math/expression_parser.cpp
ext/native/math/expression_parser.h
ext/native/math/lin/matrix4x4.cpp
ext/native/math/lin/matrix4x4.h
ext/native/math/lin/plane.cpp
ext/native/math/lin/plane.h
ext/native/math/lin/quat.cpp
ext/native/math/lin/quat.h
ext/native/math/lin/ray.h
ext/native/math/lin/vec3.cpp
ext/native/math/lin/vec3.h
ext/native/math/math_util.cpp
ext/native/math/math_util.h
ext/native/net/http_client.cpp
ext/native/net/http_client.h
ext/native/net/http_headers.cpp
ext/native/net/http_headers.h
ext/native/net/http_server.cpp
ext/native/net/http_server.h
ext/native/net/resolve.cpp
ext/native/net/resolve.h
ext/native/net/sinks.cpp
ext/native/net/sinks.h
ext/native/net/url.cpp
ext/native/net/url.h
ext/native/profiler/profiler.cpp
ext/native/profiler/profiler.h
ext/native/thin3d/thin3d.cpp
ext/native/thin3d/thin3d.h
${THIN3D_PLATFORMS}
ext/native/thread/executor.cpp
ext/native/thread/executor.h
ext/native/thread/prioritizedworkqueue.cpp
ext/native/thread/prioritizedworkqueue.h
ext/native/thread/threadutil.cpp
ext/native/thread/threadutil.h
ext/native/thread/threadpool.cpp
ext/native/thread/threadpool.h
ext/native/ui/screen.cpp
ext/native/ui/screen.h
ext/native/ui/ui.cpp
ext/native/ui/ui.h
ext/native/ui/ui_context.cpp
ext/native/ui/ui_context.h
ext/native/ui/ui_screen.cpp
ext/native/ui/ui_screen.h
ext/native/ui/view.cpp
ext/native/ui/view.h
ext/native/ui/viewgroup.cpp
ext/native/ui/viewgroup.h
ext/native/util/hash/hash.cpp
ext/native/util/hash/hash.h
ext/native/util/random/rng.h
ext/native/util/text/utf8.h
ext/native/util/text/utf8.cpp
ext/native/util/text/parsers.h
ext/native/util/text/parsers.cpp
ext/native/util/text/wrap_text.h
ext/native/util/text/wrap_text.cpp
ext/native/util/const_map.h
ext/native/ext/jpge/jpgd.cpp
ext/native/ext/jpge/jpgd.h
ext/native/ext/jpge/jpge.cpp
ext/native/ext/jpge/jpge.h)
include_directories(ext/native)
if (LINUX AND NOT ANDROID)
SET(RT_LIB rt)
endif()
SET(ATOMIC_LIB)
if(ANDROID)
SET(ATOMIC_LIB atomic)
endif()
target_link_libraries(native ${LIBZIP_LIBRARY} ${ZLIB_LIBRARY} ${PNG_LIBRARY} rg_etc1 vjson udis86 ${RT_LIB} ${nativeExtraLibs} ${ATOMIC_LIB})
if(TARGET Ext::GLEW)
target_link_libraries(native Ext::GLEW)
endif()
if(ANDROID)
target_link_libraries(native log EGL OpenSLES)
elseif(WIN32)
target_link_libraries(native ws2_32 winmm)
endif()
setup_target_project(native native)
add_library(kirk STATIC
ext/libkirk/AES.c