forked from unicorn-engine/unicorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1456 lines (1307 loc) · 45.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# CMake setup for Unicorn 2.
# By Huitao Chen & Nguyen Anh Quynh, 2019-2020
cmake_minimum_required(VERSION 3.1)
# Only required for MSVC, but we can't know the compiler at this point because we haven't
# called enable_language() or project(), and if we did that it would lock in the old
# policy. Setting these policies is harmless for non-MSVC though, so just enable them
# always.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15")
# Set explicitly the policies we want rather than raising the base to the current
# version. This prevents unintended behavior changes as CMake evolves and provides a
# consistent experience across different CMake versions.
# CMP0091: prevent msvcrt flags being added to default CMAKE_<LANG>_FLAGS_<CONFIG>
cmake_policy(SET CMP0091 NEW)
# CMP0092: prevent warning flags being added to default CMAKE_<LANG>_FLAGS for MSVC
cmake_policy(SET CMP0092 NEW)
endif()
# Workaround to fix wrong compiler on macos.
if(APPLE AND NOT CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "/usr/bin/cc")
endif()
# Detect if unicorn is compiled as the top-level project
set(PROJECT_IS_TOP_LEVEL OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PROJECT_IS_TOP_LEVEL ON)
# Enable folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
project(unicorn C)
# We depend on the availability of the CMAKE_MSVC_RUNTIME_LIBRARY, which is only
# available in CMake 3.15 and above (see also the comments above in regards to policy
# CMP0091).
if(MSVC AND CMAKE_VERSION VERSION_LESS "3.15")
message(FATAL_ERROR "Please update CMake to 3.15 or greater.")
endif()
# mainline qemu mostly just uses compiler default
set(CMAKE_C_STANDARD 11)
set(UNICORN_VERSION_MAJOR 2)
set(UNICORN_VERSION_MINOR 0)
set(UNICORN_VERSION_PATCH 1)
include(bundle_static.cmake)
# Even though we generate shared lib and static archive at the same time, we still support
# using unicorn as a subdirectory so we have to respect BUILD_SHARED_LIBS.
#
# Also we would like users to link a native cmake target, instead of a custom target for better
# compatability.
option(BUILD_SHARED_LIBS "Build shared instead of static library" ${PROJECT_IS_TOP_LEVEL})
option(UNICORN_FUZZ "Enable fuzzing" OFF)
option(UNICORN_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL})
option(UNICORN_INSTALL "Enable unicorn installation" ${PROJECT_IS_TOP_LEVEL})
set(UNICORN_ARCH "x86;arm;aarch64;riscv;mips;sparc;m68k;ppc;s390x;tricore" CACHE STRING "Enabled unicorn architectures")
option(UNICORN_TRACER "Trace unicorn execution" OFF)
foreach(ARCH_LOOP ${UNICORN_ARCH})
string(TOUPPER "${ARCH_LOOP}" ARCH_LOOP)
set(UNICORN_HAS_${ARCH_LOOP} TRUE)
endforeach()
if(MSVC)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/msvc
)
else()
include_directories(
${CMAKE_BINARY_DIR}
)
endif()
include_directories(
glib_compat
qemu
qemu/include
include
qemu/tcg
)
if(MSVC)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(MSVC_FLAG -D__x86_64__)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(MSVC_FLAG -D__i386__)
else()
message(FATAL_ERROR "Neither WIN64 or WIN32!")
endif()
add_compile_options(
-Dinline=__inline
-D__func__=__FUNCTION__
-D_CRT_SECURE_NO_WARNINGS
-DWIN32_LEAN_AND_MEAN
${MSVC_FLAG}
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/i386
)
# Disable some warnings
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4018>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4098>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4244>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:/wd4267>)
# handle msvcrt setting being passed in CMAKE_C_FLAGS
if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
# do not support other methods of setting this (it would be more conformant, tho)
message(FATAL_ERROR "please set msvcrt via CMAKE_C_FLAGS")
endif()
if(CMAKE_C_FLAGS MATCHES "[/-]MTd")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
elseif(CMAKE_C_FLAGS MATCHES "[/-]MDd")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
elseif(CMAKE_C_FLAGS MATCHES "[/-]MT")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
elseif(CMAKE_C_FLAGS MATCHES "[/-]MD")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
# prevent the arg from occurring more than once (not a big deal, just to keep tidy)
string(REGEX REPLACE "[/-]M[TD]d?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
else()
if(MINGW)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE UC_COMPILER_VERSION)
string(FIND "${UC_COMPILER_VERSION}" "i686" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "i386")
set(UNICORN_CFLAGS -m32 -static-libgcc) # Workaround for github action bugs
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
else()
set(UNICORN_TARGET_ARCH "i386")
set(UNICORN_CFLAGS -m64 -mcx16)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
endif()
elseif(ANDROID_ABI)
string(FIND "${ANDROID_ABI}" "arm64" UC_RET)
file(WRITE ${CMAKE_BINARY_DIR}/adb.sh "#!/bin/bash\n\n# Auto-generated by CMakeLists.txt\n\nadb shell mkdir -p /data/local/tmp/build\n")
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "aarch64")
else()
string(FIND "${ANDROID_ABI}" "armeabi" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "arm")
else()
set(UNICORN_TARGET_ARCH "i386")
endif()
endif()
else()
execute_process(COMMAND ${CMAKE_C_COMPILER} -dM -E -
INPUT_FILE /dev/null
OUTPUT_VARIABLE UC_COMPILER_MACRO)
while(TRUE)
string(FIND "${UC_COMPILER_MACRO}" "__x86_64__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "i386")
string(FIND "${UC_COMPILER_MACRO}" "__ILP32__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_CFLAGS -mx32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mx32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mx32")
else()
set(UNICORN_CFLAGS -m64 -mcx16)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
endif()
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__i386__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "i386")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__arm__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "arm")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__aarch64__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "aarch64")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__mips__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "mips")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__sparc__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "sparc")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__ia64__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "ia64")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "_ARCH_PPC" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "ppc")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__riscv" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "riscv")
break()
endif()
string(FIND "${UC_COMPILER_MACRO}" "__s390__" UC_RET)
if(${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "s390")
break()
endif()
string(FIND ${UC_COMPILER_MACRO} "__tricore__" UC_RET)
if (${UC_RET} GREATER_EQUAL "0")
set(UNICORN_TARGET_ARCH "tricore")
break()
endif()
message(FATAL_ERROR "Unknown host compiler: ${CMAKE_C_COMPILER}.")
endwhile(TRUE)
endif()
set(EXTRA_CFLAGS "--extra-cflags=")
if(UNICORN_HAS_X86)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_X86 ")
endif()
if(UNICORN_HAS_ARM)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_ARM ")
endif()
if(UNICORN_HAS_AARCH64)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_ARM64 ")
endif()
if(UNICORN_HAS_M68K)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_M68K ")
endif()
if(UNICORN_HAS_MIPS)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_MIPS -DUNICORN_HAS_MIPSEL -DUNICORN_HAS_MIPS64 -DUNICORN_HAS_MIPS64EL ")
endif()
if(UNICORN_HAS_SPARC)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_SPARC ")
endif()
if(UNICORN_HAS_PPC)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_PPC ")
endif()
if(UNICORN_HAS_RISCV)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_RISCV ")
endif()
if (UNICORN_HAS_S390X)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_S390X ")
endif()
if (UNICORN_HAS_TRICORE)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_TRICORE ")
endif()
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-fPIC")
if(ANDROID_ABI)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS} --target=${CMAKE_C_COMPILER_TARGET}")
set(EXTRA_CFLAGS "${EXTRA_CFLAGS} --sysroot=${CMAKE_SYSROOT}")
endif()
if(UNICORN_FUZZ)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${CMAKE_C_FLAGS}")
endif()
if(UNICORN_TRACER)
set (EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUNICORN_TRACER")
endif()
set(TARGET_LIST "--target-list=")
if(UNICORN_HAS_X86)
set(TARGET_LIST "${TARGET_LIST}x86_64-softmmu, ")
endif()
if(UNICORN_HAS_ARM)
set(TARGET_LIST "${TARGET_LIST}arm-softmmu, ")
endif()
if(UNICORN_HAS_AARCH64)
set(TARGET_LIST "${TARGET_LIST}aarch64-softmmu, ")
endif()
if(UNICORN_HAS_M68K)
set(TARGET_LIST "${TARGET_LIST}m68k-softmmu, ")
endif()
if(UNICORN_HAS_MIPS)
set(TARGET_LIST "${TARGET_LIST}mips-softmmu, mipsel-softmmu, mips64-softmmu, mips64el-softmmu, ")
endif()
if(UNICORN_HAS_SPARC)
set(TARGET_LIST "${TARGET_LIST}sparc-softmmu, sparc64-softmmu, ")
endif()
if(UNICORN_HAS_PPC)
set(TARGET_LIST "${TARGET_LIST}ppc-softmmu, ppc64-softmmu, ")
endif()
if(UNICORN_HAS_RISCV)
set(TARGET_LIST "${TARGET_LIST}riscv32-softmmu, riscv64-softmmu, ")
endif()
if(UNICORN_HAS_S390X)
set(TARGET_LIST "${TARGET_LIST}s390x-softmmu, ")
endif()
if (UNICORN_HAS_TRICORE)
set (TARGET_LIST "${TARGET_LIST}tricore-softmmu, ")
endif()
set(TARGET_LIST "${TARGET_LIST} ")
# GEN config-host.mak & target directories
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/configure
--cc=${CMAKE_C_COMPILER}
${EXTRA_CFLAGS}
${TARGET_LIST}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/config-host.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-host.h
)
if(UNICORN_HAS_X86)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/x86_64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/x86_64-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_ARM)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/arm-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/arm-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_AARCH64)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/aarch64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/aarch64-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_M68K)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/m68k-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/m68k-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_MIPS)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/mips-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips-softmmu/config-target.h
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/mipsel-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/mipsel-softmmu/config-target.h
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/mips64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips64-softmmu/config-target.h
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/mips64el-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/mips64el-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_SPARC)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/sparc-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc-softmmu/config-target.h
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/sparc64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc64-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_PPC)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/ppc-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc-softmmu/config-target.h
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/ppc64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc64-softmmu/config-target.h
)
endif()
if(UNICORN_HAS_RISCV)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.h
)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/riscv64-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/riscv64-softmmu/config-target.h
)
endif()
if (UNICORN_HAS_S390X)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/s390x-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/s390x-softmmu/config-target.h
)
endif()
if (UNICORN_HAS_TRICORE)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
INPUT_FILE ${CMAKE_BINARY_DIR}/tricore-softmmu/config-target.mak
OUTPUT_FILE ${CMAKE_BINARY_DIR}/tricore-softmmu/config-target.h
)
endif()
add_compile_options(
${UNICORN_CFLAGS}
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/${UNICORN_TARGET_ARCH}
-D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE
-Wall
-fPIC
)
if(APPLE)
# This warning is disabled by default for gcc and doesn't cause any bug.
add_compile_options(
-Wno-missing-braces
)
endif()
endif()
set(UNICORN_ARCH_COMMON
qemu/exec.c
qemu/exec-vary.c
qemu/softmmu/cpus.c
qemu/softmmu/ioport.c
qemu/softmmu/memory.c
qemu/softmmu/memory_mapping.c
qemu/fpu/softfloat.c
qemu/tcg/optimize.c
qemu/tcg/tcg.c
qemu/tcg/tcg-op.c
qemu/tcg/tcg-op-gvec.c
qemu/tcg/tcg-op-vec.c
qemu/accel/tcg/cpu-exec.c
qemu/accel/tcg/cpu-exec-common.c
qemu/accel/tcg/cputlb.c
qemu/accel/tcg/tcg-all.c
qemu/accel/tcg/tcg-runtime.c
qemu/accel/tcg/tcg-runtime-gvec.c
qemu/accel/tcg/translate-all.c
qemu/accel/tcg/translator.c
)
if(UNICORN_HAS_X86)
add_library(x86_64-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/hw/i386/x86.c
qemu/target/i386/arch_memory_mapping.c
qemu/target/i386/bpt_helper.c
qemu/target/i386/cc_helper.c
qemu/target/i386/cpu.c
qemu/target/i386/excp_helper.c
qemu/target/i386/fpu_helper.c
qemu/target/i386/helper.c
qemu/target/i386/int_helper.c
qemu/target/i386/machine.c
qemu/target/i386/mem_helper.c
qemu/target/i386/misc_helper.c
qemu/target/i386/mpx_helper.c
qemu/target/i386/seg_helper.c
qemu/target/i386/smm_helper.c
qemu/target/i386/svm_helper.c
qemu/target/i386/translate.c
qemu/target/i386/xsave_helper.c
qemu/target/i386/unicorn.c
)
if(MSVC)
target_compile_options(x86_64-softmmu PRIVATE
-DNEED_CPU_H
/FIx86_64.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/x86_64-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/i386
)
else()
target_compile_options(x86_64-softmmu PRIVATE
-DNEED_CPU_H
-include x86_64.h
-I${CMAKE_BINARY_DIR}/x86_64-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/i386
)
# Log and pow
target_link_libraries(x86_64-softmmu PRIVATE m)
endif()
if(UNICORN_TRACER)
target_compile_options(x86_64-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_ARM)
add_library(arm-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/arm/cpu.c
qemu/target/arm/crypto_helper.c
qemu/target/arm/debug_helper.c
qemu/target/arm/helper.c
qemu/target/arm/iwmmxt_helper.c
qemu/target/arm/m_helper.c
qemu/target/arm/neon_helper.c
qemu/target/arm/op_helper.c
qemu/target/arm/psci.c
qemu/target/arm/tlb_helper.c
qemu/target/arm/translate.c
qemu/target/arm/vec_helper.c
qemu/target/arm/vfp_helper.c
qemu/target/arm/unicorn_arm.c
)
if(MSVC)
target_compile_options(arm-softmmu PRIVATE
-DNEED_CPU_H
/FIarm.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/arm-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/arm
)
else()
target_compile_options(arm-softmmu PRIVATE
-DNEED_CPU_H
-include arm.h
-I${CMAKE_BINARY_DIR}/arm-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/arm
)
endif()
if(UNICORN_TRACER)
target_compile_options(arm-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_AARCH64)
add_library(aarch64-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/arm/cpu64.c
qemu/target/arm/cpu.c
qemu/target/arm/crypto_helper.c
qemu/target/arm/debug_helper.c
qemu/target/arm/helper-a64.c
qemu/target/arm/helper.c
qemu/target/arm/iwmmxt_helper.c
qemu/target/arm/m_helper.c
qemu/target/arm/neon_helper.c
qemu/target/arm/op_helper.c
qemu/target/arm/pauth_helper.c
qemu/target/arm/psci.c
qemu/target/arm/sve_helper.c
qemu/target/arm/tlb_helper.c
qemu/target/arm/translate-a64.c
qemu/target/arm/translate.c
qemu/target/arm/translate-sve.c
qemu/target/arm/vec_helper.c
qemu/target/arm/vfp_helper.c
qemu/target/arm/unicorn_aarch64.c
)
if(MSVC)
target_compile_options(aarch64-softmmu PRIVATE
-DNEED_CPU_H
/FIaarch64.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/aarch64-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/arm
)
else()
target_compile_options(aarch64-softmmu PRIVATE
-DNEED_CPU_H
-include aarch64.h
-I${CMAKE_BINARY_DIR}/aarch64-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/arm
)
endif()
if(UNICORN_TRACER)
target_compile_options(aarch64-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_M68K)
add_library(m68k-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/m68k/cpu.c
qemu/target/m68k/fpu_helper.c
qemu/target/m68k/helper.c
qemu/target/m68k/op_helper.c
qemu/target/m68k/softfloat.c
qemu/target/m68k/translate.c
qemu/target/m68k/unicorn.c
)
if(MSVC)
target_compile_options(m68k-softmmu PRIVATE
-DNEED_CPU_H
/FIm68k.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/m68k-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/m68k
)
else()
target_compile_options(m68k-softmmu PRIVATE
-DNEED_CPU_H
-include m68k.h
-I${CMAKE_BINARY_DIR}/m68k-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/m68k
)
endif()
if(UNICORN_TRACER)
target_compile_options(m68k-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_MIPS)
add_library(mips-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c
qemu/target/mips/cp0_timer.c
qemu/target/mips/cpu.c
qemu/target/mips/dsp_helper.c
qemu/target/mips/fpu_helper.c
qemu/target/mips/helper.c
qemu/target/mips/lmi_helper.c
qemu/target/mips/msa_helper.c
qemu/target/mips/op_helper.c
qemu/target/mips/translate.c
qemu/target/mips/unicorn.c
)
if(MSVC)
target_compile_options(mips-softmmu PRIVATE
-DNEED_CPU_H
/FImips.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/mips-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
else()
target_compile_options(mips-softmmu PRIVATE
-DNEED_CPU_H
-include mips.h
-I${CMAKE_BINARY_DIR}/mips-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
endif()
if(UNICORN_TRACER)
target_compile_options(mips-softmmu PRIVATE -DUNICORN_TRACER)
endif()
add_library(mipsel-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c
qemu/target/mips/cp0_timer.c
qemu/target/mips/cpu.c
qemu/target/mips/dsp_helper.c
qemu/target/mips/fpu_helper.c
qemu/target/mips/helper.c
qemu/target/mips/lmi_helper.c
qemu/target/mips/msa_helper.c
qemu/target/mips/op_helper.c
qemu/target/mips/translate.c
qemu/target/mips/unicorn.c
)
if(MSVC)
target_compile_options(mipsel-softmmu PRIVATE
-DNEED_CPU_H
/FImipsel.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/mipsel-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
else()
target_compile_options(mipsel-softmmu PRIVATE
-DNEED_CPU_H
-include mipsel.h
-I${CMAKE_BINARY_DIR}/mipsel-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
endif()
if(UNICORN_TRACER)
target_compile_options(mipsel-softmmu PRIVATE -DUNICORN_TRACER)
endif()
add_library(mips64-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c
qemu/target/mips/cp0_timer.c
qemu/target/mips/cpu.c
qemu/target/mips/dsp_helper.c
qemu/target/mips/fpu_helper.c
qemu/target/mips/helper.c
qemu/target/mips/lmi_helper.c
qemu/target/mips/msa_helper.c
qemu/target/mips/op_helper.c
qemu/target/mips/translate.c
qemu/target/mips/unicorn.c
)
if(MSVC)
target_compile_options(mips64-softmmu PRIVATE
-DNEED_CPU_H
/FImips64.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/mips64-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
else()
target_compile_options(mips64-softmmu PRIVATE
-DNEED_CPU_H
-include mips64.h
-I${CMAKE_BINARY_DIR}/mips64-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
endif()
if(UNICORN_TRACER)
target_compile_options(mips64-softmmu PRIVATE -DUNICORN_TRACER)
endif()
add_library(mips64el-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/mips/cp0_helper.c
qemu/target/mips/cp0_timer.c
qemu/target/mips/cpu.c
qemu/target/mips/dsp_helper.c
qemu/target/mips/fpu_helper.c
qemu/target/mips/helper.c
qemu/target/mips/lmi_helper.c
qemu/target/mips/msa_helper.c
qemu/target/mips/op_helper.c
qemu/target/mips/translate.c
qemu/target/mips/unicorn.c
)
if(MSVC)
target_compile_options(mips64el-softmmu PRIVATE
-DNEED_CPU_H
/FImips64el.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/mips64el-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
else()
target_compile_options(mips64el-softmmu PRIVATE
-DNEED_CPU_H
-include mips64el.h
-I${CMAKE_BINARY_DIR}/mips64el-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/mips
)
endif()
if(UNICORN_TRACER)
target_compile_options(mips64el-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_SPARC)
add_library(sparc-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/sparc/cc_helper.c
qemu/target/sparc/cpu.c
qemu/target/sparc/fop_helper.c
qemu/target/sparc/helper.c
qemu/target/sparc/int32_helper.c
qemu/target/sparc/ldst_helper.c
qemu/target/sparc/mmu_helper.c
qemu/target/sparc/translate.c
qemu/target/sparc/win_helper.c
qemu/target/sparc/unicorn.c
)
if(MSVC)
target_compile_options(sparc-softmmu PRIVATE
-DNEED_CPU_H
/FIsparc.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/sparc-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/sparc
)
else()
target_compile_options(sparc-softmmu PRIVATE
-DNEED_CPU_H
-include sparc.h
-I${CMAKE_BINARY_DIR}/sparc-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/sparc
)
endif()
if(UNICORN_TRACER)
target_compile_options(sparc-softmmu PRIVATE -DUNICORN_TRACER)
endif()
add_library(sparc64-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/sparc/cc_helper.c
qemu/target/sparc/cpu.c
qemu/target/sparc/fop_helper.c
qemu/target/sparc/helper.c
qemu/target/sparc/int64_helper.c
qemu/target/sparc/ldst_helper.c
qemu/target/sparc/mmu_helper.c
qemu/target/sparc/translate.c
qemu/target/sparc/vis_helper.c
qemu/target/sparc/win_helper.c
qemu/target/sparc/unicorn64.c
)
if(MSVC)
target_compile_options(sparc64-softmmu PRIVATE
-DNEED_CPU_H
/FIsparc64.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/sparc64-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/sparc
)
else()
target_compile_options(sparc64-softmmu PRIVATE
-DNEED_CPU_H
-include sparc64.h
-I${CMAKE_BINARY_DIR}/sparc64-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/sparc
)
endif()
if(UNICORN_TRACER)
target_compile_options(sparc64-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_PPC)
add_library(ppc-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/hw/ppc/ppc.c
qemu/hw/ppc/ppc_booke.c
qemu/libdecnumber/decContext.c
qemu/libdecnumber/decNumber.c
qemu/libdecnumber/dpd/decimal128.c
qemu/libdecnumber/dpd/decimal32.c
qemu/libdecnumber/dpd/decimal64.c
qemu/target/ppc/cpu.c
qemu/target/ppc/cpu-models.c
qemu/target/ppc/dfp_helper.c
qemu/target/ppc/excp_helper.c
qemu/target/ppc/fpu_helper.c
qemu/target/ppc/int_helper.c
qemu/target/ppc/machine.c
qemu/target/ppc/mem_helper.c
qemu/target/ppc/misc_helper.c
qemu/target/ppc/mmu-hash32.c
qemu/target/ppc/mmu_helper.c
qemu/target/ppc/timebase_helper.c
qemu/target/ppc/translate.c
qemu/target/ppc/unicorn.c
)
if(MSVC)
target_compile_options(ppc-softmmu PRIVATE
-DNEED_CPU_H
/FIppc.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/ppc-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/ppc
)
else()
target_compile_options(ppc-softmmu PRIVATE
-DNEED_CPU_H
-include ppc.h
-I${CMAKE_BINARY_DIR}/ppc-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/ppc
)
endif()
if(UNICORN_TRACER)
target_compile_options(ppc-softmmu PRIVATE -DUNICORN_TRACER)
endif()
add_library(ppc64-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/hw/ppc/ppc.c
qemu/hw/ppc/ppc_booke.c
qemu/libdecnumber/decContext.c
qemu/libdecnumber/decNumber.c
qemu/libdecnumber/dpd/decimal128.c
qemu/libdecnumber/dpd/decimal32.c
qemu/libdecnumber/dpd/decimal64.c
qemu/target/ppc/compat.c
qemu/target/ppc/cpu.c
qemu/target/ppc/cpu-models.c
qemu/target/ppc/dfp_helper.c
qemu/target/ppc/excp_helper.c
qemu/target/ppc/fpu_helper.c
qemu/target/ppc/int_helper.c
qemu/target/ppc/machine.c
qemu/target/ppc/mem_helper.c
qemu/target/ppc/misc_helper.c
qemu/target/ppc/mmu-book3s-v3.c
qemu/target/ppc/mmu-hash32.c
qemu/target/ppc/mmu-hash64.c
qemu/target/ppc/mmu_helper.c
qemu/target/ppc/mmu-radix64.c
qemu/target/ppc/timebase_helper.c
qemu/target/ppc/translate.c
qemu/target/ppc/unicorn.c
)
if(MSVC)
target_compile_options(ppc64-softmmu PRIVATE
-DNEED_CPU_H
/FIppc64.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/ppc64-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/ppc
)
else()
target_compile_options(ppc64-softmmu PRIVATE
-DNEED_CPU_H
-include ppc64.h
-I${CMAKE_BINARY_DIR}/ppc64-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/ppc
)
endif()
if(UNICORN_TRACER)
target_compile_options(ppc64-softmmu PRIVATE -DUNICORN_TRACER)
endif()
endif()
if(UNICORN_HAS_RISCV)
add_library(riscv32-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/riscv/cpu.c
qemu/target/riscv/cpu_helper.c
qemu/target/riscv/csr.c
qemu/target/riscv/fpu_helper.c
qemu/target/riscv/op_helper.c
qemu/target/riscv/pmp.c
qemu/target/riscv/translate.c
qemu/target/riscv/unicorn.c
)
if(MSVC)
target_compile_options(riscv32-softmmu PRIVATE
-DNEED_CPU_H
/FIriscv32.h
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/riscv32-softmmu
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/riscv
)
else()
target_compile_options(riscv32-softmmu PRIVATE
-DNEED_CPU_H
-include riscv32.h
-I${CMAKE_BINARY_DIR}/riscv32-softmmu
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/riscv
)
endif()
if(UNICORN_TRACER)
target_compile_options(riscv32-softmmu PRIVATE -DUNICORN_TRACER)
endif()
add_library(riscv64-softmmu STATIC
${UNICORN_ARCH_COMMON}
qemu/target/riscv/cpu.c
qemu/target/riscv/cpu_helper.c
qemu/target/riscv/csr.c
qemu/target/riscv/fpu_helper.c
qemu/target/riscv/op_helper.c
qemu/target/riscv/pmp.c
qemu/target/riscv/translate.c
qemu/target/riscv/unicorn.c
)
if(MSVC)
target_compile_options(riscv64-softmmu PRIVATE
-DNEED_CPU_H