-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1623 lines (1527 loc) · 46.4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# vim:noexpandtab:
cmake_minimum_required(VERSION 2.8.8)
project(PPSSPP)
enable_language(ASM)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
add_definitions(-DPPSSPP)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_ARCH_64 1)
add_definitions(-D_ARCH_64=1)
else()
set(_ARCH_32 1)
add_definitions(-D_ARCH_32=1)
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)
endif()
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)
endif()
endif()
# Remove soon?
set(USE_FFMPEG ON)
if(ARM OR SIMULATOR)
set(USING_EGL ON)
endif()
if(EXISTS "/opt/vc/include/bcm_host.h")
message(STATUS "RaspberryPI VC Found")
set(RPI ON)
endif()
if(BB)
set(ARMV7 ON)
set(USING_FBDEV ON)
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 (X86 AND NOT MIPS)
if(_ARCH_64)
add_definitions(-D_M_X64)
else()
add_definitions(-D_M_IX86)
endif()
endif()
if(NOT DEFINED HEADLESS)
set(HEADLESS OFF)
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})
# :: Platforms
option(ANDROID "Set to ON if targeting an Android device" ${ANDROID})
option(BLACKBERRY "Set to ON if targeting a Blackberry device" ${BLACKBERRY})
option(IOS "Set to ON if targeting an iOS device" ${IOS})
option(MAEMO "Set to ON if targeting a Maemo (N900) device" ${MAEMO})
option(BB "Set to ON if targeting a Beaglebone/Beaglebone Black device" ${BB})
# :: 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})
# :: 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 targetting 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})
if(ANDROID OR BLACKBERRY OR IOS)
if (NOT CMAKE_TOOLCHAIN_FILE)
if (ANDROID)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/android/android.toolchain.cmake)
elseif(BLACKBERRY)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/Blackberry/bb.toolchain.cmake)
elseif(IOS)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/ios/ios.toolchain.cmake)
endif()
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was not set!\n"
"Delete the CMakeCache.txt file and CMakeFiles directory.\n"
"Re-run ${CMAKE_COMMAND} with:\n"
"\"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}\"")
endif()
set(MOBILE_DEVICE ON)
set(USING_GLES2 ON)
endif()
if(ANDROID)
set(CoreLibName ppsspp_jni)
set(CoreLinkType SHARED)
else()
set(CoreLibName Core)
set(CoreLinkType STATIC)
endif()
include_directories(native)
if(RPI)
include_directories(/opt/vc/include /opt/vc/include/interface/vcos/pthreads)
link_directories(/opt/vc/lib)
set(OPENGL_LIBRARIES GLESv2 bcm_host)
elseif(USING_GLES2 AND NOT IOS)
set(OPENGL_LIBRARIES GLESv2)
elseif(NOT IOS)
include(FindOpenGL REQUIRED)
endif()
if(MAEMO)
#Maemo's gcc-4.7.2 is strict
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif()
if (NOT BLACKBERRY AND NOT ANDROID AND NOT IOS)
include(FindSDL2)
endif()
include(FindThreads)
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
endif()
# Needed for Globals.h
include_directories("${CMAKE_SOURCE_DIR}")
if(ARM)
add_definitions(-DARM)
endif()
if(MIPS)
add_definitions(-DMIPS)
endif()
if(ANDROID)
add_definitions(-DANDROID)
endif()
if(BLACKBERRY)
add_definitions(-DBLACKBERRY=${BLACKBERRY})
endif()
if(IOS)
add_definitions(-DIOS)
endif()
if(MAEMO)
add_definitions(-DMAEMO)
endif()
if(RPI)
add_definitions(-DRPI)
endif()
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()
if(ARMV7)
message("Building for ARMv7, ${CMAKE_BUILD_TYPE}")
elseif(ARM)
message("Building for ARMv6, ${CMAKE_BUILD_TYPE}")
elseif(MIPS AND X86)
message("Building for MIPS in x86 mode, ${CMAKE_BUILD_TYPE}")
elseif(MIPS)
message("Buildings for MIPS, ${CMAKE_BUILD_TYPE}")
elseif(X86)
message("Building for x86, ${CMAKE_BUILD_TYPE}")
else()
message("Building for Generic, ${CMAKE_BUILD_TYPE}")
endif()
if(NOT MSVC)
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")
# Disable some warnings
add_definitions(-Wno-multichar)
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 AND NOT MIPS)
# enable sse2 code generation
add_definitions(-msse2)
endif()
if (BLACKBERRY AND ARM)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
endif()
if(IOS)
add_definitions(-DGL_ETC1_RGB8_OES=0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -U__STRICT_ANSI__")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
# armv7s (without resorting to FastMemory) is still a work in progress
# comment out the next line to enable default/"standard" architectures (which is a fat armv7/armv7s binary)
set(CMAKE_OSX_ARCHITECTURES "armv7")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -U__STRICT_ANSI__")
# Karen/angelXwind: --macosx-version-min=10.7 is needed in order to produce binaries that OS X 10.7 Lion can execute. However, it seems that PPSSPP won't support 10.6 or lower without getting rid of -stdlib=libc++ ...which probably won't end well. So I guess PPSSPP will strictly be a 10.7+ app.
# vit9696: OSX 10.6 builds are possible: http://forums.ppsspp.org/showthread.php?tid=1826&pid=18875#pid18875
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
else()
if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_definitions(-Wno-psabi)
endif()
add_definitions(-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1)
add_definitions(-D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
# Disable warnings about MS-specific _s variants of libc functions
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_NDEBUG")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
if(ANDROID)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/android/libs/${ANDROID_ABI}")
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(CommonExtra)
if(ARM)
set(CommonExtra ${CommonExtra}
Common/ArmCPUDetect.cpp
Common/ArmThunk.cpp)
elseif(X86)
set(CommonExtra ${CommonExtra}
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)
elseif(MIPS)
set(CommonExtra ${CommonExtra}
Common/MipsCPUDetect.cpp
Common/MipsEmitter.cpp
Common/MipsEmitter.h)
else()
set(CommonExtra ${CommonExtra}
Common/FakeCPUDetect.cpp
Common/FakeEmitter.h)
endif()
# ARMEmitter is here for the unit tests and don't really hurt otherwise.
set(CommonExtra ${CommonExtra}
Common/ArmEmitter.h
Common/ArmEmitter.cpp)
if(WIN32)
set(CommonExtra ${CommonExtra}
Common/stdafx.cpp
Common/stdafx.h)
endif()
add_library(Common STATIC
${CommonExtra}
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/LogManager.h
Common/MemArena.cpp
Common/MemArena.h
Common/MemoryUtil.cpp
Common/MemoryUtil.h
Common/Misc.cpp
Common/MsgHandler.cpp
Common/MsgHandler.h
Common/StringUtils.cpp
Common/StringUtils.h
Common/ThreadPools.cpp
Common/ThreadPools.h
Common/Timer.cpp
Common/Timer.h)
include_directories(Common)
setup_target_project(Common Common)
if(WIN32)
target_link_libraries(Common winmm)
endif()
if(NOT USING_GLES2)
include_directories(${OPENGL_INCLUDE_DIR})
add_definitions(-DGLEW_STATIC)
add_library(glew STATIC
native/ext/glew/GL/glew.h
native/ext/glew/GL/glxew.h
native/ext/glew/GL/wglew.h
native/ext/glew/glew.c)
target_link_libraries(glew ${OPENGL_LIBRARIES})
include_directories(native/ext/glew)
set(GLEW_LIBRARIES glew)
endif()
add_subdirectory(ext/snappy)
add_subdirectory(ext/udis86)
add_library(vjson STATIC
native/ext/vjson/json.cpp
native/ext/vjson/json.h
native/ext/vjson/block_allocator.cpp
native/ext/vjson/block_allocator.h
)
add_library(rg_etc1 STATIC
native/ext/rg_etc1/rg_etc1.cpp
native/ext/rg_etc1/rg_etc1.h)
include_directories(native/ext/rg_etc1)
add_library(stb_vorbis STATIC
native/ext/stb_vorbis/stb_vorbis.c
native/ext/stb_vorbis/stb_vorbis.h)
include_directories(native/ext/stb_vorbis)
if(USE_FFMPEG AND NOT DEFINED FFMPEG_BUILDDIR)
if(ANDROID)
if(ARMV7)
set(PLATFORM_ARCH "android/armv7")
elseif(ARM)
set(PLATFORM_ARCH "android/arm")
elseif(X86)
set(PLATFORM_ARCH "android/x86")
endif()
elseif(BLACKBERRY)
set(PLATFORM_ARCH "blackberry/armv7")
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(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")
else()
set(PLATFORM_ARCH "linux/x86")
endif()
endif()
# Using static libraries
if (DEFINED PLATFORM_ARCH)
include_directories(ffmpeg/${PLATFORM_ARCH}/include)
link_directories(ffmpeg/${PLATFORM_ARCH}/lib)
set(FFMPEG_LIBRARIES libavformat.a libavcodec.a libavutil.a libswresample.a libswscale.a)
else()
# Manual definition of system library locations by the user.
if (DEFINED FFMPEG_INCLUDE_PATH)
include_directories(ffmpeg ${FFMPEG_INCLUDE_PATH})
endif()
if (DEFINED AVFORMAT_PATH)
add_library(libavformat STATIC IMPORTED)
set_target_properties(libavformat PROPERTIES IMPORTED_LOCATION ${AVFORMAT_PATH})
SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libavformat)
endif()
if (DEFINED AVCODEC_PATH)
add_library(libavcodec STATIC IMPORTED)
set_target_properties(libavcodec PROPERTIES IMPORTED_LOCATION ${AVCODEC_PATH})
SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libavcodec)
endif()
if (DEFINED AVUTIL_PATH)
add_library(libavutil STATIC IMPORTED)
set_target_properties(libavutil PROPERTIES IMPORTED_LOCATION ${AVUTIL_PATH})
SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libavutil)
endif()
if (DEFINED SWRESAMPLE_PATH)
add_library(libswresample STATIC IMPORTED)
set_target_properties(libswresample PROPERTIES IMPORTED_LOCATION ${SWRESAMPLE_PATH})
SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libswresample)
endif()
if (DEFINED SWSCALE_PATH)
add_library(libswscale STATIC IMPORTED)
set_target_properties(libswscale PROPERTIES IMPORTED_LOCATION ${SWSCALE_PATH})
SET (FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} libswscale)
endif()
endif(DEFINED PLATFORM_ARCH)
endif(USE_FFMPEG AND NOT DEFINED FFMPEG_BUILDDIR)
if(USE_FFMPEG)
# Using shared libraries
if(DEFINED FFMPEG_BUILDDIR)
include_directories(ffmpeg ${FFMPEG_BUILDDIR})
add_library(libavformat STATIC IMPORTED)
set_target_properties(libavformat PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libavformat/libavformat.a)
add_library(libavcodec STATIC IMPORTED)
set_target_properties(libavcodec PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libavcodec/libavcodec.a)
add_library(libavutil STATIC IMPORTED)
set_target_properties(libavutil PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libavutil/libavutil.a)
add_library(libswresample STATIC IMPORTED)
set_target_properties(libswresample PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libswresample/libswresample.a)
add_library(libswscale STATIC IMPORTED)
set_target_properties(libswscale PROPERTIES IMPORTED_LOCATION ${FFMPEG_BUILDDIR}/libswscale/libswscale.a)
SET (FFMPEG_LIBRARIES
libavformat
libavcodec
libavutil
libswresample
libswscale
)
endif()
find_library(ICONV_LIBRARY NAMES iconv)
if (ICONV_LIBRARY)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${ICONV_LIBRARY})
endif()
if(APPLE)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} bz2 "-framework CoreVideo")
if (NOT IOS)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "-framework VideoDecodeAcceleration")
endif()
endif(APPLE)
set(LinkCommon ${LinkCommon} ${FFMPEG_LIBRARIES})
add_definitions(-DUSE_FFMPEG)
endif(USE_FFMPEG)
# Modification to show where we are pulling the ffmpeg libraries from.
if(USE_FFMPEG AND DEFINED FFMPEG_LIBRARIES)
target_link_libraries(Common ${FFMPEG_LIBRARIES})
message(STATUS "FFMPEG library locations:")
if(DEFINED PLATFORM_ARCH)
set(TEMP ${CMAKE_SOURCE_DIR}/ffmpeg/${PLATFORM_ARCH}/lib)
message(STATUS "libavcodec location: ${TEMP}/libavcodec.a")
message(STATUS "libavformat location: ${TEMP}/libavformat.a")
message(STATUS "libavutil location: ${TEMP}/libavutil.a")
message(STATUS "libswresample location: ${TEMP}/libswresample.a")
message(STATUS "libswscale location: ${TEMP}/libswscale.a")
else()
get_target_property(TEMP libavcodec IMPORTED_LOCATION)
message(STATUS "libavcodec location: ${TEMP}")
get_target_property(TEMP libavformat IMPORTED_LOCATION)
message(STATUS "libavformat location: ${TEMP}")
get_target_property(TEMP libavutil IMPORTED_LOCATION)
message(STATUS "libavutil location: ${TEMP}")
get_target_property(TEMP libswresample IMPORTED_LOCATION)
message(STATUS "libswresample location: ${TEMP}")
get_target_property(TEMP libswscale IMPORTED_LOCATION)
message(STATUS "libswscale location: ${TEMP}")
endif(DEFINED PLATFORM_ARCH)
else()
message(STATUS "ERROR: No FFMPEG library locations")
endif()
if(USE_FFMPEG AND NOT DEFINED FFMPEG_LIBRARIES)
message(WARNING "FFMPEG_BUILDDIR variable or manual path definition is required to enable FFmpeg. Disabling it.")
unset(USE_FFMPEG)
endif()
find_package(ZLIB)
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIR})
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
native/ext/cityhash/city.cpp
native/ext/cityhash/city.h
native/ext/cityhash/citycrc.h
)
include_directories(ext/cityhash)
if (NOT MSVC)
# These can be fast even for debug.
set_target_properties(snappy PROPERTIES COMPILE_FLAGS "-O3")
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()
add_library(libzip STATIC
native/ext/libzip/zip.h
native/ext/libzip/mkstemp.c
native/ext/libzip/zip_add.c
native/ext/libzip/zip_add_dir.c
native/ext/libzip/zip_close.c
native/ext/libzip/zip_delete.c
native/ext/libzip/zip_dirent.c
native/ext/libzip/zip_entry_free.c
native/ext/libzip/zip_entry_new.c
native/ext/libzip/zip_err_str.c
native/ext/libzip/zip_error.c
native/ext/libzip/zip_error_clear.c
native/ext/libzip/zip_error_get.c
native/ext/libzip/zip_error_get_sys_type.c
native/ext/libzip/zip_error_strerror.c
native/ext/libzip/zip_error_to_str.c
native/ext/libzip/zip_fclose.c
native/ext/libzip/zip_file_error_clear.c
native/ext/libzip/zip_file_error_get.c
native/ext/libzip/zip_file_get_offset.c
native/ext/libzip/zip_file_strerror.c
native/ext/libzip/zip_filerange_crc.c
native/ext/libzip/zip_fopen.c
native/ext/libzip/zip_fopen_index.c
native/ext/libzip/zip_fread.c
native/ext/libzip/zip_free.c
native/ext/libzip/zip_get_archive_comment.c
native/ext/libzip/zip_get_archive_flag.c
native/ext/libzip/zip_get_file_comment.c
native/ext/libzip/zip_get_name.c
native/ext/libzip/zip_get_num_files.c
native/ext/libzip/zip_memdup.c
native/ext/libzip/zip_name_locate.c
native/ext/libzip/zip_new.c
native/ext/libzip/zip_open.c
native/ext/libzip/zip_rename.c
native/ext/libzip/zip_replace.c
native/ext/libzip/zip_set_archive_comment.c
native/ext/libzip/zip_set_archive_flag.c
native/ext/libzip/zip_set_file_comment.c
native/ext/libzip/zip_set_name.c
native/ext/libzip/zip_source_buffer.c
native/ext/libzip/zip_source_file.c
native/ext/libzip/zip_source_filep.c
native/ext/libzip/zip_source_free.c
native/ext/libzip/zip_source_function.c
native/ext/libzip/zip_source_zip.c
native/ext/libzip/zip_stat.c
native/ext/libzip/zip_stat_index.c
native/ext/libzip/zip_stat_init.c
native/ext/libzip/zip_strerror.c
native/ext/libzip/zip_unchange.c
native/ext/libzip/zip_unchange_all.c
native/ext/libzip/zip_unchange_archive.c
native/ext/libzip/zip_unchange_data.c)
target_link_libraries(libzip ${ZLIB_LIBRARY})
include_directories(native/ext/libzip)
set(LIBZIP_LIBRARY libzip)
# 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)
file(GLOB PNG_ARM_INCLUDES native/ext/libpng17/arm/*)
endif()
add_library(png17 STATIC
native/ext/libpng17/pngconf.h
native/ext/libpng17/pngdebug.h
native/ext/libpng17/png.c
native/ext/libpng17/png.h
native/ext/libpng17/pngerror.c
native/ext/libpng17/pngget.c
native/ext/libpng17/pnginfo.h
native/ext/libpng17/pnglibconf.h
native/ext/libpng17/pngmem.c
native/ext/libpng17/pngpread.c
native/ext/libpng17/pngpriv.h
native/ext/libpng17/pngread.c
native/ext/libpng17/pngrio.c
native/ext/libpng17/pngrtran.c
native/ext/libpng17/pngrutil.c
native/ext/libpng17/pngset.c
native/ext/libpng17/pngstruct.h
native/ext/libpng17/pngtest.c
native/ext/libpng17/pngtrans.c
native/ext/libpng17/pngwio.c
native/ext/libpng17/pngwrite.c
native/ext/libpng17/pngwtran.c
native/ext/libpng17/pngwutil.c
${PNG_ARM_INCLUDES} )
set(PNG_LIBRARY png17)
include_directories(native/ext)
endif()
set(nativeExtra)
set(nativeExtraLibs)
if(ARMV7)
if(BB)
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a8")
else()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a -mfpu=neon -mcpu=cortex-a9")
endif()
set(nativeExtra ${nativeExtra}
native/math/fast/fast_matrix_neon.S)
endif()
if(X86 AND NOT MIPS)
set(nativeExtra ${nativeExtra}
native/math/fast/fast_matrix_sse.c)
endif()
if(ANDROID)
set(nativeExtra ${nativeExtra}
native/base/NativeApp.h
native/android/app-android.cpp
native/android/native_audio.cpp
native/android/native_audio.h)
add_library(native_audio SHARED
native/android/native-audio-so.cpp
native/android/native-audio-so.h)
target_link_libraries(native_audio OpenSLES log)
# No target
elseif(IOS)
set(nativeExtra ${nativeExtra}
ios/main.mm
ios/AppDelegate.m
ios/AppDelegate.h
ios/ViewController.mm
ios/ViewController.h
ios/iOSCoreAudio.cpp
ios/iOSCoreAudio.h
ios/iCade/iCadeReaderView.h
ios/iCade/iCadeReaderView.m
ios/iCade/iCadeState.h)
set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit -framework GLKit -framework OpenAL")
if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework")
set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController")
endif()
set_source_files_properties(ios/AppDelegate.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
set_source_files_properties(ios/ViewController.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
set(TargetBin PPSSPP)
elseif(USING_QT_UI)
# Currently unused
message(FATAL_ERROR "Cmake does not yet support Qt. Please use qmake instead.")
find_package(Qt4 COMPONENTS QtMultimedia QtOpenGL QtGui QtCore)
include(${QT_USE_FILE})
qt4_wrap_cpp(nativeQtHeader native/base/QtMain.h)
set(nativeExtra ${nativeExtra} native/base/QtMain.cpp ${nativeQtHeader})
if(NOT MOBILE_DEVICE)
qt4_wrap_cpp(nativeQtHeader Qt/mainwindow.h)
set(nativeExtra ${nativeExtra} Qt/mainwindow.cpp)
endif()
set(nativeExtraLibs ${nativeExtraLibs} ${QT_LIBRARIES})
set(TargetBin PPSSPPQt)
if(APPLE)
set(nativeExtraLibs ${nativeExtraLibs} "-framework CoreFoundation")
endif()
elseif(BLACKBERRY)
unset(CMAKE_DL_LIBS)
set(nativeExtra ${nativeExtra} native/base/BlackberryMain.cpp native/base/BlackberryDisplay.cpp)
set(nativeExtraLibs ${nativeExtraLibs} OpenAL bps screen socket EGL)
set(TargetBin PPSSPPBlackberry)
elseif(SDL2_FOUND)
set(TargetBin PPSSPPSDL)
# Require SDL
include_directories(${SDL2_INCLUDE_DIR})
add_definitions(-DSDL)
set(nativeExtra ${nativeExtra}
SDL/SDLJoystick.h
SDL/SDLJoystick.cpp
native/base/PCMain.cpp)
set(nativeExtraLibs ${nativeExtraLibs} ${SDL2_LIBRARY})
if(APPLE)
set(nativeExtra ${nativeExtra} SDL/SDLMain.h SDL/SDLMain.mm)
set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY})
elseif(USING_EGL)
set(nativeExtraLibs ${nativeExtraLibs} pthread EGL)
endif()
set(TargetBin PPSSPPSDL)
else()
message(FATAL_ERROR "Could not find SDL2. Failing.")
endif()
set(NativeAppSource
android/jni/TestRunner.cpp
UI/NativeApp.cpp
UI/BackgroundAudio.cpp
UI/DevScreens.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/ReportScreen.cpp
UI/Store.cpp
UI/CwCheatScreen.cpp
UI/InstallZipScreen.cpp
UI/ui_atlas.cpp)
if(ANDROID)
if (ARM)
set(NativeAppSource ${NativeAppSource} android/jni/ArmEmitterTest.cpp)
endif()
set(nativeExtra ${nativeExtra} ${NativeAppSource})
endif()
add_library(native STATIC
${nativeExtra}
native/base/backtrace.cpp
native/base/backtrace.h
native/audio/mixer.cpp
native/audio/mixer.h
native/audio/wav_read.cpp
native/audio/wav_read.h
native/base/basictypes.h
native/base/buffer.cpp
native/base/buffer.h
native/base/color.h
native/base/colorutil.cpp
native/base/colorutil.h
native/base/display.cpp
native/base/display.h
native/base/error_context.cpp
native/base/error_context.h
native/base/fastlist.h
native/base/fastlist_test.cpp
native/base/functional.h
native/base/linked_ptr.h
native/base/logging.h
native/base/mutex.h
native/base/scoped_ptr.h
native/base/stats.h
native/base/stringutil.cpp
native/base/stringutil.h
native/base/timeutil.cpp
native/base/timeutil.h
native/data/compression.cpp
native/data/compression.h
native/ext/vjson/json.cpp
native/ext/vjson/json.h
native/ext/vjson/block_allocator.cpp
native/ext/vjson/block_allocator.h
native/file/chunk_file.cpp
native/file/chunk_file.h
native/file/dialog.cpp
native/file/dialog.h
native/file/easy_file.cpp
native/file/easy_file.h
native/file/fd_util.cpp
native/file/fd_util.h
native/file/file_util.cpp
native/file/file_util.h
native/file/ini_file.cpp
native/file/ini_file.h
native/file/path.cpp
native/file/path.h
native/file/vfs.h
native/file/zip_read.cpp
native/file/zip_read.h
native/gfx/gl_common.h
native/gfx/gl_debug_log.cpp
native/gfx/gl_debug_log.h
native/gfx/gl_lost_manager.cpp
native/gfx/gl_lost_manager.h
native/gfx/texture.cpp
native/gfx/texture.h
native/gfx/texture_atlas.cpp
native/gfx/texture_atlas.h
# native/gfx/texture_dx11.cpp
native/gfx/texture_gen.cpp
native/gfx/texture_gen.h
native/gfx_es2/draw_buffer.cpp
native/gfx_es2/draw_buffer.h
native/gfx_es2/draw_text.cpp
native/gfx_es2/draw_text.h
native/gfx_es2/fbo.cpp
native/gfx_es2/fbo.h
native/gfx_es2/gl_state.cpp
native/gfx_es2/gl_state.h
native/gfx_es2/gpu_features.cpp
native/gfx_es2/gpu_features.h
native/gfx_es2/glsl_program.cpp
native/gfx_es2/glsl_program.h
native/gfx_es2/vertex_format.cpp
native/gfx_es2/vertex_format.h
native/gfx_es2/gl3stub.c
native/gfx_es2/gl3stub.h
native/i18n/i18n.cpp
native/i18n/i18n.h
native/image/png_load.cpp
native/image/png_load.h
native/image/zim_load.cpp
native/image/zim_load.h
native/image/zim_save.cpp
native/image/zim_save.h
native/input/gesture_detector.cpp
native/input/gesture_detector.h
native/input/keycodes.h
native/input/input_state.h
native/input/input_state.cpp
native/math/fast/fast_math.c
native/math/fast/fast_matrix.c
native/math/curves.cpp
native/math/curves.h
native/math/expression_parser.cpp
native/math/expression_parser.h
native/math/lin/aabb.cpp
native/math/lin/aabb.h
native/math/lin/matrix4x4.cpp
native/math/lin/matrix4x4.h
native/math/lin/plane.cpp
native/math/lin/plane.h
native/math/lin/quat.cpp
native/math/lin/quat.h
native/math/lin/ray.h
native/math/lin/vec3.cpp
native/math/lin/vec3.h
native/math/math_util.cpp
native/math/math_util.h
native/net/http_client.cpp
native/net/http_client.h
native/net/resolve.cpp
native/net/resolve.h
native/net/url.cpp
native/net/url.h
native/profiler/profiler.cpp
native/profiler/profiler.h
native/thin3d/thin3d.cpp
native/thin3d/thin3d.h
native/thin3d/thin3d_gl.cpp
native/thread/prioritizedworkqueue.cpp
native/thread/prioritizedworkqueue.h
native/thread/threadutil.cpp
native/thread/threadutil.h
native/thread/threadpool.cpp
native/thread/threadpool.h
native/ui/screen.cpp
native/ui/screen.h
native/ui/ui.cpp
native/ui/ui.h
native/ui/ui_context.cpp
native/ui/ui_context.h
native/ui/ui_screen.cpp
native/ui/ui_screen.h
native/ui/view.cpp
native/ui/view.h
native/ui/viewgroup.cpp
native/ui/viewgroup.h
native/ui/virtual_input.cpp
native/ui/virtual_input.h
native/util/bits/bits.cpp
native/util/bits/bits.h
native/util/bits/hamming.h
native/util/bits/varint.cpp
native/util/bits/varint.h
native/util/hash/hash.cpp
native/util/hash/hash.h
native/util/random/perlin.cpp
native/util/random/perlin.h
native/util/random/rng.h
native/util/text/utf8.h
native/util/text/utf8.cpp
native/util/text/parsers.h
native/util/text/parsers.cpp
native/util/const_map.h
native/ext/jpge/jpgd.cpp
native/ext/jpge/jpgd.h
native/ext/jpge/jpge.cpp
native/ext/jpge/jpge.h)
include_directories(native)
if (LINUX AND NOT ANDROID)
SET(RT_LIB rt)
endif()
target_link_libraries(native ${LIBZIP_LIBRARY} ${PNG_LIBRARY} rg_etc1 vjson stb_vorbis snappy udis86 ${RT_LIB} ${GLEW_LIBRARIES})
if(ANDROID)
target_link_libraries(native log EGL)
elseif(WIN32)
target_link_libraries(native ws2_32 winmm)
endif()
setup_target_project(native native)
add_library(kirk STATIC
ext/libkirk/AES.c
ext/libkirk/AES.h
ext/libkirk/amctrl.c