forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
525 lines (459 loc) · 18.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
cmake_minimum_required(VERSION 3.14.5)
project(mono)
include(GNUInstallDirs)
include(CheckIncludeFile)
include(CheckFunctionExists)
include(TestBigEndian)
include(FindPkgConfig)
include(CheckCCompilerFlag)
include("cmake/QuietOSXRanlib.cmake")
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
set(CMAKE_INSTALL_MESSAGE LAZY)
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)
function(process_enable_minimal)
string(REPLACE "," ";" tmp1 "${ENABLE_MINIMAL}")
foreach(arg ${tmp1})
string(TOUPPER "${arg}" var1)
set(DISABLE_${var1} 1 PARENT_SCOPE)
endforeach(arg)
endfunction()
if(ENABLE_MINIMAL)
process_enable_minimal()
endif()
execute_process(
COMMAND grep ^MONO_CORLIB_VERSION= ${CMAKE_SOURCE_DIR}/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(EXISTS "${CMAKE_SOURCE_DIR}/mono.proj")
set(ENABLE_NETCORE 1)
endif()
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)
set(DISABLE_CONFIG 1)
set(DISABLE_CFGDIR_CONFIG 1)
set(DISABLE_VERIFIER 1)
else()
message(FATAL_ERROR "Building without -DENABLE_NETCORE=1 is not supported.")
endif()
# Dependencies between options
if(DISABLE_ASSEMBLY_REMAPPING)
set(DISABLE_DESKTOP_LOADER 1)
endif()
if(ENABLE_INTERP_LIB)
set(DISABLE_INTERPRETER 1)
endif()
if(NOT DISABLE_INTERPRETER OR NOT DISABLE_JIT)
set(ENABLE_ILGEN 1)
endif()
if(NOT DISABLE_EVENTPIPE)
set(ENABLE_PERFTRACING 1)
endif()
if(ENABLE_LAZY_GC_THREAD_CREATION)
set(LAZY_GC_THREAD_CREATION 1)
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(HAVE_MOVING_COLLECTOR 1)
set(HAVE_CONC_GC_AS_DEFAULT 1)
set(MONO_INSIDE_RUNTIME 1)
# FIXME:
set(NAME_DEV_RANDOM "/dev/random")
######################################
# AOT CROSS COMPILER SUPPORT
######################################
if(NOT AOT_TARGET_TRIPLE STREQUAL "")
set(MONO_CROSS_COMPILE 1)
add_definitions(-DNO_GLOBALIZATION_SHIM)
if(NOT AOT_OFFSETS_FILE STREQUAL "")
set(MONO_OFFSETS_FILE "${AOT_OFFSETS_FILE}")
endif()
if(AOT_TARGET_TRIPLE STREQUAL "x86_64-apple-darwin10")
set(TARGET_SYSTEM_NAME "iOS")
set(TARGET_ARCH "x86_64")
elseif(AOT_TARGET_TRIPLE STREQUAL "i386-apple-darwin10")
set(TARGET_SYSTEM_NAME "iOS")
set(TARGET_ARCH "x86")
elseif(AOT_TARGET_TRIPLE STREQUAL "aarch64-apple-darwin10")
set(TARGET_SYSTEM_NAME "iOS")
set(TARGET_ARCH "arm64")
elseif(AOT_TARGET_TRIPLE STREQUAL "arm-apple-darwin10")
set(TARGET_SYSTEM_NAME "iOS")
set(TARGET_ARCH "arm")
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-none")
set(TARGET_SYSTEM_NAME "Emscripten")
set(TARGET_ARCH "wasm")
else()
message(FATAL_ERROR "AOT target '${AOT_TARGET_TRIPLE}' not supported.")
endif()
endif()
######################################
# GCC CHECKS
######################################
if(GCC)
# We require C99 with some GNU extensions, e.g. `linux` macro
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -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 -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wno-unused-function")
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set(WARNINGS "${WARNINGS} -Qunused-arguments -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand -Wno-zero-length-array")
endif()
check_c_compiler_flag("-Werror=incompatible-pointer-types" WERROR_INCOMPATIBLE_POINTER_TYPES)
if(WERROR_INCOMPATIBLE_POINTER_TYPES)
set(WERROR "-Werror=incompatible-pointer-types")
endif()
set(WERROR "-Werror=return-type -Werror-implicit-function-declaration")
append("${WARNINGS} ${WERROR}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
set(MONO_ZERO_LEN_ARRAY 0)
if(ENABLE_WERROR)
append("-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
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)
if (GC_SUSPEND STREQUAL "default")
set(GC_SUSPEND "hybrid")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS")
# See man cmake-toolchains(7) on which variables
# control cross-compiling to ios
add_definitions(-DNO_GLOBALIZATION_SHIM)
add_definitions(-D_THREAD_SAFE)
set(HOST_DARWIN 1)
set(HOST_IOS 1)
set(PTHREAD_POINTER_ID 1)
set(USE_MACH_SEMA 1)
set(DISABLE_EXECUTABLES 1)
set(DISABLE_CRASH_REPORTING 1)
set(ENABLE_MONOTOUCH 1)
add_definitions(-DMONOTOUCH=1)
set(HAVE_SYSTEM 0)
if(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
set(HOST_TVOS 1)
endif()
# Force some defines
set(HAVE_GETPWUID_R 0)
set(HAVE_SYS_USER_H 0)
set(HAVE_GETENTROPY 0)
if(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
set(HAVE_PTHREAD_KILL 0)
set(HAVE_KILL 0)
set(HAVE_SIGACTION 0)
set(HAVE_FORK 0)
set(HAVE_EXECV 0)
set(HAVE_EXECVE 0)
set(HAVE_EXECVP 0)
set(HAVE_SIGNAL 0)
endif()
add_definitions("-DSMALL_CONFIG")
add_definitions("-D_XOPEN_SOURCE")
add_definitions("-DHAVE_LARGE_FILE_SUPPORT=1")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(HOST_LINUX 1)
add_definitions(-D_GNU_SOURCE -D_REENTRANT)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
set(HOST_LINUX 1)
add_definitions(-D_GNU_SOURCE -D_REENTRANT)
# The normal check fails because it uses --isystem <ndk root>/sysroot/usr/include
set(HAVE_USR_INCLUDE_MALLOC_H 1)
set(HOST_ANDROID 1)
set(ANDROID_UNIFIED_HEADERS 1)
set(ENABLE_MONODROID 1)
set(DISABLE_EXECUTABLES 1)
set(GC_SUSPEND "hybrid")
# Force some defines
set(HAVE_SCHED_GETAFFINITY 0)
set(HAVE_SCHED_SETAFFINITY 0)
# FIXME: Rest of the flags from configure.ac
elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(HOST_WASM 1)
set(TARGET_ARCH "wasm")
# CMAKE_SYSTEM_PROCESSOR is set to x86
set(CMAKE_SYSTEM_PROCESSOR "wasm")
set(DISABLE_EXECUTABLES 1)
# FIXME: Is there a cmake option for this ?
set(DISABLE_SHARED_LIBS 1)
else()
message(FATAL_ERROR "Host '${CMAKE_SYSTEM_NAME}' not supported.")
endif()
######################################
# TARGET OS CHECKS
######################################
if(NOT TARGET_SYSTEM_NAME)
set(TARGET_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
endif()
if(TARGET_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_MACH 1)
set(TARGET_OSX 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "iOS" OR TARGET_SYSTEM_NAME STREQUAL "tvOS")
set(TARGET_MACH 1)
set(TARGET_IOS 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "Linux")
elseif(TARGET_SYSTEM_NAME STREQUAL "Android")
set(TARGET_ANDROID 1)
elseif(TARGET_SYSTEM_NAME STREQUAL "Emscripten")
set(TARGET_WASM 1)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options(-Os)
endif()
else()
message(FATAL_ERROR "Target '${TARGET_SYSTEM_NAME}' not supported.")
endif()
######################################
# HOST ARCH CHECKS
######################################
if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_OSX_ARCHITECTURES}")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
set(CMAKE_SYSTEM_PROCESSOR "x86")
endif()
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(HOST_AMD64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "i686")
# i686 is used on android
set(HOST_X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(HOST_ARM64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set(HOST_ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "wasm")
else()
message(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}' not supported.")
endif()
######################################
# TARGET ARCH CHECKS
######################################
if(NOT TARGET_ARCH)
set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
endif()
if(TARGET_ARCH STREQUAL "x86_64")
set(TARGET_AMD64 1)
set(MONO_ARCHITECTURE "\"amd64\"")
elseif(TARGET_ARCH STREQUAL "x86" OR TARGET_ARCH STREQUAL "i686")
set(TARGET_X86 1)
set(MONO_ARCHITECTURE "\"x86\"")
elseif(TARGET_ARCH STREQUAL "arm64" OR TARGET_ARCH STREQUAL "aarch64")
set(TARGET_ARM64 1)
set(MONO_ARCHITECTURE "\"arm64\"")
elseif(TARGET_ARCH MATCHES "arm")
set(TARGET_ARM 1)
set(MONO_ARCHITECTURE "\"arm\"")
# FIXME:
if(TARGET_IOS OR TARGET_ANDROID)
add_definitions("-DARM_FPU_VFP=1")
endif()
elseif(TARGET_ARCH STREQUAL "wasm")
set(MONO_ARCHITECTURE "\"wasm\"")
else()
message(FATAL_ERROR "TARGET_ARCH='${TARGET_ARCH}' not supported.")
endif()
######################################
# LLVM CHECKS
######################################
set(LLVM_LIBS)
if(LLVM_PREFIX)
if(TARGET_ARCH STREQUAL "x86_64")
set(llvm_codegen_libs "x86codegen")
elseif(TARGET_ARCH STREQUAL "x86")
set(llvm_codegen_libs "x86codegen")
elseif(TARGET_ARCH STREQUAL "arm64" OR TARGET_ARCH STREQUAL "aarch64")
set(llvm_codegen_libs "aarch64codegen")
elseif(TARGET_ARCH STREQUAL "arm")
set(llvm_codegen_libs "armcodegen")
elseif(TARGET_ARCH STREQUAL "wasm")
set(llvm_codegen_libs "")
else()
message(FATAL_ERROR "FIXME: ${TARGET_ARCH}")
endif()
if(CMAKE_CROSSCOMPILING)
# Can't run llvm-config, hardcode results
set(llvm_config_path "${LLVM_PREFIX}/include/llvm/Config/llvm-config.h")
# llvm-config --mono-api-version
find_program(AWK awk mawk gawk)
execute_process(COMMAND /bin/sh -c "\"${AWK}\" '/MONO_API_VERSION/ { print $3 }' ${llvm_config_path}" RESULT_VARIABLE awk_res OUTPUT_VARIABLE llvm_api_version OUTPUT_STRIP_TRAILING_WHITESPACE)
# llvm-config --cflags
set(llvm_cflags "-I${LLVM_PREFIX}/include")
set(llvm_cxxflags "-I${LLVM_PREFIX}/include")
# llvm-config --system-libs
set(llvm_system_libs "-lz -lrt -ldl -lpthread -lm")
# llvm-config --libs analysis core bitwriter mcjit orcjit
set(llvm_core_libs "-lLLVMOrcJIT -lLLVMJITLink -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle")
# Check codegen libs and add needed libraries.
if("${llvm_codegen_libs}" STREQUAL "x86codegen")
# llvm-config --libs x86codegen
set(llvm_extra "-lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Utils -lLLVMX86Info -lLLVMMCDisassembler -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle")
elseif("${llvm_codegen_libs}" STREQUAL "armcodegen")
# llvm-config --libs armcodegen
set(llvm_extra "-lLLVMARMCodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBinaryFormat -lLLVMARMUtils -lLLVMARMInfo -lLLVMSupport -lLLVMDemangle")
elseif("${llvm_codegen_libs}" STREQUAL "aarch64codegen")
# llvm-config --libs aarch64codegen
set(llvm_extra "-lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMBitstreamReader -lLLVMCore -lLLVMRemarks -lLLVMAArch64Desc -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBinaryFormat -lLLVMAArch64Utils -lLLVMAArch64Info -lLLVMSupport -lLLVMDemangle")
else()
message(FATAL_ERROR "FIXME: ${TARGET_ARCH}")
endif()
set(llvm_libs ${llvm_core_libs} ${llvm_extra})
else()
set(LLVM_CONFIG ${LLVM_PREFIX}/bin/llvm-config)
if (NOT EXISTS ${LLVM_CONFIG})
message(FATAL_ERROR "LLVM executable '${LLVM_CONFIG}' not found.")
endif()
execute_process(COMMAND ${LLVM_CONFIG} --mono-api-version RESULT_VARIABLE llvm_config_res OUTPUT_VARIABLE llvm_api_version OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT ${llvm_config_res} EQUAL 0)
message(FATAL_ERROR "'${LLVM_CONFIG} --mono-api-version' failed. Use the llvm fork at https://github.com/dotnet/llvm-project.")
endif()
execute_process(COMMAND ${LLVM_CONFIG} --cflags OUTPUT_VARIABLE llvm_cflags OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --cxxflags OUTPUT_VARIABLE llvm_cxxflags OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --system-libs OUTPUT_VARIABLE llvm_system_libs OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${LLVM_CONFIG} --libs analysis core bitwriter mcjit orcjit ${llvm_codegen_libs} OUTPUT_VARIABLE llvm_libs OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if (${llvm_api_version} LESS 900)
message(FATAL_ERROR "LLVM version too old.")
endif()
set(ENABLE_LLVM 1)
set(ENABLE_LLVM_RUNTIME 1)
set(LLVM_LIBS ${llvm_libs} ${llvm_system_libs})
set(LLVM_LIBDIR "${LLVM_PREFIX}/lib")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${llvm_cflags}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${llvm_cxxflags} -fexceptions -fno-rtti")
add_definitions(-DLLVM_API_VERSION=${llvm_api_version})
endif()
######################################
# ICU CHECKS
######################################
set(ICU_SHIM_PATH "../../../libraries/Native/Unix/System.Globalization.Native")
if(MONO_CROSS_COMPILE)
elseif(TARGET_OSX)
# FIXME: Handle errors
# Defines ICU_INCLUDEDIR/ICU_LIBDIR
set(ENV{PKG_CONFIG_PATH} "{$PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig")
pkg_check_modules(ICU icu-uc)
set(OSX_ICU_LIBRARY_PATH /usr/lib/libicucore.dylib)
set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations")
set(HAVE_SYS_ICU 1)
elseif(TARGET_WASM)
#set(ICU_CFLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE")
set(ICU_FLAGS "-DPALEXPORT=\"\" -DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option")
set(HAVE_SYS_ICU 1)
set(STATIC_ICU 1)
set(ICU_LIBS "icucore")
elseif(TARGET_IOS)
# FIXME:
elseif(TARGET_ANDROID)
set(ICU_FLAGS "-DPALEXPORT=\"\" -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -DTARGET_ANDROID -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option")
set(HAVE_SYS_ICU 1)
elseif(HOST_LINUX)
pkg_check_modules(ICU icu-uc)
set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations")
set(HAVE_SYS_ICU 1)
else()
message(FATAL_ERROR "")
endif()
######################################
# GC CHECKS
######################################
if (GC_SUSPEND STREQUAL "coop")
set(ENABLE_COOP_SUSPEND 1)
elseif(GC_SUSPEND STREQUAL "hybrid")
set(ENABLE_HYBRID_SUSPEND 1)
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()
add_subdirectory(mono)
configure_file(cmake/config.h.in config.h)
configure_file(cmake/eglib-config.h.cmake.in mono/eglib/eglib-config.h)