forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
219 lines (179 loc) · 5.41 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
cmake_minimum_required (VERSION 3.10)
project (mono)
include(GNUInstallDirs)
include(CheckIncludeFile)
include(CheckFunctionExists)
include(TestBigEndian)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
function(append value)
foreach(variable ${ARGN})
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
endforeach(variable)
endfunction()
# User options
include(options)
# Header/function checks
include(configure)
# FIXME:
set(VERSION "")
execute_process(
COMMAND grep ^MONO_CORLIB_VERSION= configure.ac
COMMAND cut -d = -f 2
OUTPUT_VARIABLE CORLIB_VERSION_OUT
)
if (CORLIB_VERSION_OUT STREQUAL "")
message(FATAL_ERROR)
endif()
string(STRIP "${CORLIB_VERSION_OUT}" MONO_CORLIB_VERSION_BASE)
set(MONO_CORLIB_VERSION "\"${MONO_CORLIB_VERSION_BASE}\"")
if (ENABLE_NETCORE)
set(DISABLE_REMOTING 1)
set(DISABLE_REFLECTION_EMIT_SAVE 1)
set(DISABLE_APPDOMAINS 1)
set(DISABLE_CLEANUP 1)
set(DISABLE_ASSEMBLY_REMAPPING 1)
set(DISABLE_SECURITY 1)
set(DISABLE_MDB 1)
set(DISABLE_COM 1)
set(DISABLE_GAC 1)
set(DISABLE_PERFCOUNTERS 1)
set(DISABLE_ATTACH 1)
set(DISABLE_DLLMAP 1)
else()
message(FATAL_ERROR "Building without -DENABLE_NETCORE=1 is not supported.")
endif()
#FIXME:
set(VERSION "\"\"")
set(DISABLED_FEATURES "\"\"")
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
set (GCC 1)
endif ()
add_definitions(-g)
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-D_THREAD_SAFE)
if (GCC)
add_definitions(-fPIC)
add_definitions(-DMONO_DLL_EXPORT)
add_definitions(-fvisibility=hidden)
endif()
set(USE_GCC_ATOMIC_OPS 1)
set(HAVE_CLASSIC_WINAPI_SUPPORT 1)
set(ENABLE_ILGEN 1)
set(HAVE_MOVING_COLLECTOR 1)
set(HAVE_CONC_GC_AS_DEFAULT 1)
set(MONO_INSIDE_RUNTIME 1)
######################################
# GCC CHECKS
######################################
if(GCC)
# We require C99 with some GNU extensions, e.g. `linux` macro
add_definitions(-std=gnu99)
# The runtime code does not respect ANSI C strict aliasing rules
append("-fno-strict-aliasing" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# We rely on signed overflow to behave
append("-fwrapv" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
set(WARNINGS "-Wall -Wunused -Wmissing-declarations -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes -Qunused-arguments -Wno-unused-function -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand -Wno-zero-length-array -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length")
set(WERROR "-Werror=incompatible-pointer-types -Werror=return-type -Werror-implicit-function-declaration")
append("${WARNINGS} ${WERROR}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
######################################
# HOST OS CHECKS
######################################
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions(-D_THREAD_SAFE)
set(HOST_DARWIN 1)
set(PTHREAD_POINTER_ID 1)
set(USE_MACH_SEMA 1)
else()
message(FATAL ERROR "")
endif()
######################################
# TARGET OS CHECKS
######################################
# FIXME:
set(TARGET_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
if(TARGET_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_MACH 1)
set(TARGET_OSX 1)
set(RID_PREFIX "osx")
set(CORETARGETS "-p:TargetsUnix=true -p:TargetsOSX=true")
set(NETCORE_HOST_PLATFORM "macos")
else()
message(FATAL ERROR "")
endif()
######################################
# HOST ARCH CHECKS
######################################
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(HOST_AMD64 1)
else()
message(FATAL ERROR "")
endif()
######################################
# TARGET ARCH CHECKS
######################################
# FIXME:
set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
if(TARGET_ARCH STREQUAL "x86_64")
set(TARGET_AMD64 1)
set(MONO_ARCHITECTURE "\"amd64\"")
set(RID_SUFFIX "x64")
set(COREARCH "x64")
else()
message(FATAL ERROR "")
endif()
######################################
# EGLIB CHECKS
######################################
set (GNUC_PRETTY)
set (GNUC_UNUSED)
set (BREAKPOINT "G_STMT_START { raise (SIGTRAP); } G_STMT_END")
if (GCC)
set (GNUC_UNUSED "__attribute__((__unused__))")
set (GNUC_NORETURN "__attribute__((__noreturn__))")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86|x86_64")
set (BREAKPOINT "G_STMT_START { __asm__ (\"int \$03\"); } G_STMT_END")
endif ()
endif ()
if (IS_BIG_ENDIAN)
set (ORDER G_BIG_ENDIAN)
else ()
set (ORDER G_LITTLE_ENDIAN)
endif ()
if (WIN32)
# FIXME:
message (FATAL_ERROR "FIXME")
else ()
set(PATHSEP "/")
set(SEARCHSEP ":")
set(OS "UNIX")
set(PIDTYPE "int")
endif ()
# FIXME:
set(GSIZE_FORMAT "\"lu\"")
set(GSIZE "size_t")
set(GSSIZE "ptrdiff_t")
#
# END OF EGLIB CHECKS
#
TEST_BIG_ENDIAN (IS_BIG_ENDIAN)
# FIXME:
set(TARGET_SIZEOF_VOID_P "${SIZEOF_VOID_P}")
set(SIZEOF_REGISTER "${SIZEOF_VOID_P}")
if (IS_BIG_ENDIAN)
set(TARGET_BYTE_ORDER G_BIG_ENDIAN)
else()
set(TARGET_BYTE_ORDER G_LITTLE_ENDIAN)
endif()
set (RID "${RID_PREFIX}-${RID_SUFFIX}")
add_subdirectory (mono)
configure_file (cmake/config.h.in config.h)
configure_file (cmake/eglib-config.h.cmake.in mono/eglib/eglib-config.h)
configure_file (cmake/netcore-config.make.in netcore/config.make)