forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
337 lines (297 loc) · 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
cmake_minimum_required(VERSION 3.2)
project (CHAKRACORE)
# Keep CMake from caching static/shared library
# option. Otherwise, CMake fails to update cached
# references
if(SHARED_LIBRARY_SH)
unset(SHARED_LIBRARY_SH CACHE)
unset(STATIC_LIBRARY_SH CACHE)
unset(STATIC_LIBRARY CACHE)
set(SHARED_LIBRARY 1)
endif()
if(STATIC_LIBRARY_SH)
unset(SHARED_LIBRARY_SH CACHE)
unset(STATIC_LIBRARY_SH CACHE)
unset(SHARED_LIBRARY CACHE)
set(STATIC_LIBRARY 1)
endif()
if(CC_TARGETS_AMD64_SH)
unset(CC_TARGETS_X86 CACHE)
unset(CC_TARGETS_X86_SH CACHE)
unset(CC_TARGETS_AMD64_SH CACHE)
set(CC_TARGETS_AMD64 1)
endif()
if(CC_TARGETS_X86_SH)
unset(CC_TARGETS_X86_SH CACHE)
unset(CC_TARGETS_AMD64_SH CACHE)
unset(CC_TARGETS_AMD64 CACHE)
set(CC_TARGETS_X86 1)
set(CMAKE_SYSTEM_PROCESSOR "i386")
endif()
if(ICU_SETTINGS_RESET)
unset(ICU_SETTINGS_RESET CACHE)
unset(ICU_INCLUDE_PATH CACHE)
unset(ICU_INCLUDE_PATH_SH CACHE)
unset(NO_ICU_PATH_GIVEN_SH CACHE)
unset(NO_ICU_PATH_GIVEN CACHE)
unset(CC_EMBED_ICU_SH CACHE)
endif()
if(CC_EMBED_ICU_SH)
unset(CC_EMBED_ICU_SH CACHE)
set(CC_EMBED_ICU 1)
set(ICU_INCLUDE_PATH "deps/icu/source/output/include/")
add_definitions(-DU_STATIC_IMPLEMENTATION)
endif()
if(ICU_INCLUDE_PATH_SH)
set(ICU_INCLUDE_PATH ${ICU_INCLUDE_PATH_SH})
unset(NO_ICU_PATH_GIVEN_SH CACHE)
unset(NO_ICU_PATH_GIVEN CACHE)
unset(ICU_INCLUDE_PATH_SH CACHE)
endif()
if(NO_ICU_PATH_GIVEN_SH)
set(NO_ICU_PATH_GIVEN ${NO_ICU_PATH_GIVEN_SH})
unset(NO_ICU_PATH_GIVEN_SH CACHE)
unset(ICU_INCLUDE_PATH_SH CACHE)
unset(ICU_INCLUDE_PATH CACHE)
endif()
function(clr_unknown_arch)
if (WIN32)
message(FATAL_ERROR "Only AMD64, ARM and I386 are supported")
else()
message(FATAL_ERROR "Only AMD64 and I386 are supported")
endif()
endfunction()
if(ICU_INCLUDE_PATH)
add_definitions(-DHAS_REAL_ICU=1)
set(ICU_CC_PATH "${ICU_INCLUDE_PATH}/../lib/")
find_library(ICUUC icuuc PATHS ${ICU_CC_PATH} NO_DEFAULT_PATH)
find_library(ICU18 icui18n PATHS ${ICU_CC_PATH} NO_DEFAULT_PATH)
find_library(ICUDATA icudata PATHS ${ICU_CC_PATH} NO_DEFAULT_PATH)
if(ICUUC)
message("found libraries on ${ICU_CC_PATH}")
set(ICULIB
${ICUUC}
${ICU18}
${ICUDATA}
)
endif()
elseif(CC_EMBED_ICU)
set(ICU_CC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../deps/icu/source/output/lib/")
find_library(ICUUC icuuc PATHS ${ICU_CC_PATH} NO_DEFAULT_PATH)
find_library(ICU18 icui18n PATHS ${ICU_CC_PATH} NO_DEFAULT_PATH)
find_library(ICUDATA icudata PATHS ${ICU_CC_PATH} NO_DEFAULT_PATH)
set(ICULIB
${ICUUC}
${ICU18}
${ICUDATA}
)
endif()
set(CLR_CMAKE_PLATFORM_XPLAT 1)
if(CC_TARGETS_AMD64)
add_definitions(-D_M_X64_OR_ARM64)
add_compile_options(-msse4.1)
elseif(CC_TARGETS_X86)
add_definitions(-D__i686__)
add_definitions(-D_M_IX86_OR_ARM32)
add_compile_options(-arch i386)
add_compile_options(-msse3)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
-m32"
)
else()
clr_unknown_arch()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(NOT ICULIB)
if(NOT NO_ICU_PATH_GIVEN)
if(NOT CC_EMBED_ICU)
set(ICULIB "icuuc")
endif()
add_definitions(-DHAS_REAL_ICU=1)
endif()
endif()
set(CLR_CMAKE_PLATFORM_LINUX 1)
# OSX 10.12 Clang deprecates libstdc++ [See GH #1599]
# So, -Werror is linux only for now
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Werror"
)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
add_definitions(
-DPLATFORM_UNIX
)
if(NOT ICULIB)
if(NOT NO_ICU_PATH_GIVEN)
add_definitions(-DHAS_REAL_ICU=1)
if(NOT CC_EMBED_ICU)
set(ICULIB "icucore")
add_definitions(
-DU_DISABLE_RENAMING=1 #in case we link against to an older binary of icu
)
endif()
message("using ICU from system default: ${ICULIB}")
endif()
endif()
if(NOT CC_XCODE_PROJECT)
set(CLR_CMAKE_PLATFORM_DARWIN 1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-mmacosx-version-min=10.7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mmacosx-version-min=10.7")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} \
-mmacosx-version-min=10.7")
endif()
else()
message(FATAL_ERROR "This OS is not supported")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang
OR CMAKE_CXX_COMPILER_ID STREQUAL Clang
OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
# Color diagnostics for g++ and clang++
add_definitions("-fdiagnostics-color=always")
endif()
if(STATIC_LIBRARY)
add_definitions(-DCHAKRA_STATIC_LIBRARY=1)
endif()
if(CLR_CMAKE_PLATFORM_XPLAT)
add_definitions(-DPLATFORM_UNIX=1)
if(CLR_CMAKE_PLATFORM_LINUX)
add_definitions(-D__LINUX__=1)
if(CC_TARGETS_AMD64)
add_definitions(-DLINUX64)
endif(CC_TARGETS_AMD64)
endif(CLR_CMAKE_PLATFORM_LINUX)
if(CC_TARGETS_AMD64)
set(IS_64BIT_BUILD 1)
add_definitions(-D_M_X64 -D_M_AMD64 -D_AMD64_)
endif(CC_TARGETS_AMD64)
add_definitions(
-DUNICODE
-D_SAFECRT_USE_CPP_OVERLOADS=1
-D__STDC_WANT_LIB_EXT1__=1
)
set(CMAKE_CXX_STANDARD 11)
# CC WARNING FLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-Wno-implicit-function-declaration"
)
# todo: fix general visibility of the interface
# do not set to `fvisibility=hidden` as it is going to
# prevent the required interface is being exported
# clang by default sets fvisibility=default
# CXX WARNING FLAGS
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wno-ignored-attributes\
-Wno-deprecated-declarations\
-Wno-parentheses-equality\
-Wno-missing-braces\
-Wno-reorder\
-Wno-microsoft\
-Wno-unused-value\
-Wno-int-to-void-pointer-cast\
-Wno-invalid-offsetof\
-Wno-undefined-inline\
-Wno-inconsistent-missing-override\
-Wno-c++14-extensions\
-Wno-macro-redefined\
-Wno-pragmas\
-Wno-invalid-token-paste\
-Wno-format\
-Wno-invalid-noreturn\
-Wno-null-arithmetic\
-Wno-tautological-constant-out-of-range-compare\
-Wno-tautological-undefined-compare\
-Wno-address-of-temporary\
-Wno-null-conversion\
-Wno-return-type\
-Wno-switch\
-Wno-int-to-pointer-cast"
)
# notes..
# -Wno-address-of-temporary # vtinfo.h, VirtualTableInfo<T>::RegisterVirtualTable
# -Wno-null-conversion # Check shmemory.cpp and cs.cpp here...
# -Wno-return-type # switch unreachable code
# -Wno-switch # switch values not handled
# xplat-todo for release build
# -fno-inline.... -> -mno-omit.... are needed for more accurate stack inf.
# Release Builds: Not sure if this has to be as strict as the debug/test?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-fdelayed-template-parsing\
-fno-omit-frame-pointer\
-fno-optimize-sibling-calls\
-mno-omit-leaf-frame-pointer" # this is for compat reasons. i.e. It is a noop with gcc
)
# CXX / CC COMPILER FLAGS
add_compile_options(
-fasm-blocks
-fms-extensions
-fwrapv # Treat signed integer overflow as two's complement
)
# Clang -fsanitize.
if (CLANG_SANITIZE_SH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${CLANG_SANITIZE_SH}")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsanitize=${CLANG_SANITIZE_SH}")
unset(CLANG_SANITIZE_SH CACHE) # don't cache
endif()
endif(CLR_CMAKE_PLATFORM_XPLAT)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(
-DDBG=1
-DDEBUG=1
-D_DEBUG=1 # for PAL
-DDBG_DUMP=1
)
elseif(CMAKE_BUILD_TYPE STREQUAL Test)
add_definitions(
-DENABLE_DEBUG_CONFIG_OPTIONS=1
)
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-O3"
)
endif(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
if(IS_64BIT_BUILD)
add_definitions(
-DBIT64=1
-DSTACK_ALIGN=16
)
endif(IS_64BIT_BUILD)
if(CLR_CMAKE_PLATFORM_XPLAT)
add_definitions(-DFEATURE_PAL)
endif(CLR_CMAKE_PLATFORM_XPLAT)
if(NO_JIT_SH
OR CLR_CMAKE_PLATFORM_DARWIN) # TODO: JIT for OSX
unset(NO_JIT_SH CACHE) # don't cache
unset(BuildJIT CACHE) # also clear it just in case
add_definitions(-DDISABLE_JIT=1)
else()
set(BuildJIT 1)
endif()
if(WITHOUT_FEATURES_SH)
unset(WITHOUT_FEATURES_SH CACHE) # don't cache
add_definitions(${WITHOUT_FEATURES_SH})
endif(WITHOUT_FEATURES_SH)
enable_language(ASM)
include_directories(
.
lib/Common
lib/Common/PlaceHolder
pal
pal/inc
pal/inc/rt
${ICU_INCLUDE_PATH}
)
if(ICU_INCLUDE_PATH)
if(NOT HAVE_LIBICU_UCHAR_H)
set(HAVE_LIBICU_UCHAR_H "1")
endif()
endif()
add_subdirectory (pal)
# build the rest with NO_PAL_MINMAX and PAL_STDCPP_COMPAT
add_definitions(
-DNO_PAL_MINMAX
-DPAL_STDCPP_COMPAT
)
add_subdirectory (lib)
add_subdirectory (bin)