-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCMakeLists.txt
118 lines (91 loc) · 2.94 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
cmake_minimum_required(VERSION 2.8)
include (ExternalProject)
project (tlib)
option (DEBUG "Debug mode" OFF)
option (HOST_BIG_ENDIAN "Host big endian" OFF)
set (HOST_ARCH "i386" CACHE STRING "Host architecture")
set (HOST_WORD_SIZE "64" CACHE STRING "Host word size")
option (TARGET_BIG_ENDIAN "Target big endian" OFF)
set (TARGET_ARCH "" CACHE STRING "Target architecture")
set (TARGET_WORD_SIZE "32" CACHE STRING "Target word size")
# this must be placed after setting default values for:
# TARGET_BIG_ENDIAN, HOST_WORD_SIZE, TARGET_WORD_SIZE
ExternalProject_Add (tcglib
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tcg
PREFIX tcg
CMAKE_ARGS -DBIG_ENDIAN:BOOL=${TARGET_BIG_ENDIAN} -DHOST_LONG_BITS:INT=${HOST_WORD_SIZE} -DTARGET_LONG_BITS:INT=${TARGET_WORD_SIZE}
INSTALL_COMMAND "")
set_property (CACHE HOST_ARCH PROPERTY STRINGS i386 arm)
set_property (CACHE TARGET_ARCH PROPERTY STRINGS i386 arm arm-m sparc ppc)
if(NOT HOST_ARCH)
message (FATAL_ERROR "Host architecture not set")
endif()
if(NOT TARGET_ARCH)
message (FATAL_ERROR "Target architecture not set")
endif()
string (TOUPPER "${HOST_ARCH}" HOST_ARCH_U)
string (TOUPPER "${TARGET_ARCH}" TARGET_ARCH_U)
if(TARGET_BIG_ENDIAN)
add_definitions (
-DTARGET_WORDS_BIGENDIAN=1)
endif()
if(HOST_WORD_SIZE EQUAL 64)
add_definitions (-fPIC)
endif()
if(DEBUG)
add_definitions (-g3)
else()
add_definitions (-O2)
endif()
add_definitions (-Wall)
add_definitions (-Wextra)
add_definitions (-Wno-unused-parameter)
add_definitions (-Wno-sign-compare)
set (TARGET_ACTUAL_ARCH ${TARGET_ARCH})
if("${TARGET_ARCH}" STREQUAL "arm-m")
set (TARGET_ACTUAL_ARCH "arm")
endif()
string (TOUPPER "${TARGET_ACTUAL_ARCH}" TARGET_ACTUAL_ARCH_U)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
add_definitions (
-DCONFIG_NEED_MMU
-DCONFIG_${HOST_ARCH_U}_DIS=1
-DCONFIG_${TARGET_ACTUAL_ARCH_U}_DIS=1
-DTCG_TARGET_${HOST_ARCH_U}
-DHOST_BITS_${HOST_WORD_SIZE}
-DHOST_${HOST_ARCH_U}=1
-DHOST_LONG_BITS=${HOST_WORD_SIZE}
-DTARGET_SHORT_ALIGNMENT=2
-DTARGET_INT_ALIGNMENT=4
-DTARGET_LONG_ALIGNMENT=4
-DTARGET_LLONG_ALIGNMENT=4
-DTARGET_ARCH=${TARGET_ACTUAL_ARCH}
-DTARGET_${TARGET_ACTUAL_ARCH_U}=1
-DTARGET_LONG_BITS=${TARGET_LONG_BITS})
if("${TARGET_ARCH}" STREQUAL "arm-m")
add_definitions (-DTARGET_PROTO_ARM_M=1)
endif()
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fomit-frame-pointer")
if(${HOST_WORD_SIZE} EQUAL 64)
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--wrap=memcpy")
endif()
include_directories (
tcg
fpu
include
include_empty
tcg/${HOST_ARCH}
arch/${TARGET_ACTUAL_ARCH})
file (GLOB SOURCES
"*.c"
"fpu/*.c"
"arch/*.c"
"external/*.c"
"arch/${TARGET_ACTUAL_ARCH}/*.c")
add_library (tlib SHARED ${SOURCES})
add_dependencies (tlib tcglib)
target_link_libraries (tlib
m
rt
pthread
${CMAKE_CURRENT_BINARY_DIR}/tcg/src/tcglib-build/libtcg.a)