forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configureplatform.cmake
427 lines (383 loc) · 16.4 KB
/
configureplatform.cmake
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
include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake)
# If set, indicates that this is not an officially supported release
# Keep in sync with IsPrerelease in Directory.Build.props
set(PRERELEASE 1)
#----------------------------------------
# Detect and set platform variable names
# - for non-windows build platform & architecture is detected using inbuilt CMAKE variables and cross target component configure
# - for windows we use the passed in parameter to CMAKE to determine build arch
#----------------------------------------
set(CLR_CMAKE_HOST_OS ${CMAKE_SYSTEM_NAME})
if(CLR_CMAKE_HOST_OS STREQUAL Linux)
set(CLR_CMAKE_HOST_UNIX 1)
if(CLR_CROSS_COMPONENTS_BUILD)
# CMAKE_HOST_SYSTEM_PROCESSOR returns the value of `uname -p` on host.
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
if(CLR_CMAKE_TARGET_ARCH STREQUAL "arm" OR CLR_CMAKE_TARGET_ARCH STREQUAL "armel")
if(CMAKE_CROSSCOMPILING)
set(CLR_CMAKE_HOST_UNIX_X86 1)
else()
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
endif()
else()
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
endif()
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL i686)
set(CLR_CMAKE_HOST_UNIX_X86 1)
else()
clr_unknown_arch()
endif()
else()
# CMAKE_SYSTEM_PROCESSOR returns the value of `uname -p` on target.
# For the AMD/Intel 64bit architecture two different strings are common.
# Linux and Darwin identify it as "x86_64" while FreeBSD and netbsd uses the
# "amd64" string. Accept either of the two here.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
set(CLR_CMAKE_HOST_UNIX_ARMV7L 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686 OR CMAKE_SYSTEM_PROCESSOR STREQUAL x86)
set(CLR_CMAKE_HOST_UNIX_X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390x)
set(CLR_CMAKE_HOST_UNIX_S390X 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64)
set(CLR_CMAKE_HOST_UNIX_MIPS64 1)
else()
clr_unknown_arch()
endif()
endif()
set(CLR_CMAKE_HOST_LINUX 1)
# Detect Linux ID
set(LINUX_ID_FILE "/etc/os-release")
if(CMAKE_CROSSCOMPILING)
set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}")
endif()
if(EXISTS ${LINUX_ID_FILE})
execute_process(
COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID"
OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(DEFINED CLR_CMAKE_LINUX_ID)
if(CLR_CMAKE_LINUX_ID STREQUAL tizen)
set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
elseif(CLR_CMAKE_LINUX_ID STREQUAL alpine)
set(CLR_CMAKE_HOST_ALPINE_LINUX 1)
set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID})
endif()
endif(DEFINED CLR_CMAKE_LINUX_ID)
endif(CLR_CMAKE_HOST_OS STREQUAL Linux)
if(CLR_CMAKE_HOST_OS STREQUAL Darwin)
set(CLR_CMAKE_HOST_UNIX 1)
if(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
set(CLR_CMAKE_HOST_MACCATALYST 1)
else()
set(CLR_CMAKE_HOST_OSX 1)
endif(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
if(CMAKE_OSX_ARCHITECTURES STREQUAL x86_64)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL arm64)
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
else()
clr_unknown_arch()
endif()
set(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_C_COMPILER} <FLAGS> <DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
endif(CLR_CMAKE_HOST_OS STREQUAL Darwin)
if(CLR_CMAKE_HOST_OS STREQUAL iOS OR CLR_CMAKE_HOST_OS STREQUAL iOSSimulator)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_IOS 1)
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(CLR_CMAKE_HOST_UNIX_X86 1)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "armv7")
set(CLR_CMAKE_HOST_UNIX_ARM 1)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
else()
clr_unknown_arch()
endif()
endif(CLR_CMAKE_HOST_OS STREQUAL iOS OR CLR_CMAKE_HOST_OS STREQUAL iOSSimulator)
if(CLR_CMAKE_HOST_OS STREQUAL tvOS OR CLR_CMAKE_HOST_OS STREQUAL tvOSSimulator)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_TVOS 1)
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
else()
clr_unknown_arch()
endif()
endif(CLR_CMAKE_HOST_OS STREQUAL tvOS OR CLR_CMAKE_HOST_OS STREQUAL tvOSSimulator)
if(CLR_CMAKE_HOST_OS STREQUAL Android)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_LINUX 1)
set(CLR_CMAKE_HOST_ANDROID 1)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
set(CLR_CMAKE_HOST_UNIX_ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
set(CLR_CMAKE_HOST_UNIX_ARM64 1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
set(CLR_CMAKE_HOST_UNIX_X86 1)
else()
clr_unknown_arch()
endif()
endif(CLR_CMAKE_HOST_OS STREQUAL Android)
if(CLR_CMAKE_HOST_OS STREQUAL FreeBSD)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
set(CLR_CMAKE_HOST_FREEBSD 1)
endif(CLR_CMAKE_HOST_OS STREQUAL FreeBSD)
if(CLR_CMAKE_HOST_OS STREQUAL OpenBSD)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
set(CLR_CMAKE_HOST_OPENBSD 1)
endif(CLR_CMAKE_HOST_OS STREQUAL OpenBSD)
if(CLR_CMAKE_HOST_OS STREQUAL NetBSD)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
set(CLR_CMAKE_HOST_NETBSD 1)
endif(CLR_CMAKE_HOST_OS STREQUAL NetBSD)
if(CLR_CMAKE_HOST_OS STREQUAL SunOS)
set(CLR_CMAKE_HOST_UNIX 1)
EXECUTE_PROCESS(
COMMAND isainfo -n
OUTPUT_VARIABLE SUNOS_NATIVE_INSTRUCTION_SET)
if(SUNOS_NATIVE_INSTRUCTION_SET MATCHES "amd64" OR CMAKE_CROSSCOMPILING)
set(CLR_CMAKE_HOST_UNIX_AMD64 1)
set(CMAKE_SYSTEM_PROCESSOR "amd64")
else()
clr_unknown_arch()
endif()
EXECUTE_PROCESS(
COMMAND uname -o
OUTPUT_VARIABLE SUNOS_KERNEL_KIND
ERROR_QUIET)
set(CLR_CMAKE_HOST_SUNOS 1)
if(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING)
set(CLR_CMAKE_HOST_OS_ILLUMOS 1)
else(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING)
set(CLR_CMAKE_HOST_OS_SOLARIS 1)
endif(SUNOS_KERNEL_KIND STREQUAL illumos OR CMAKE_CROSSCOMPILING)
endif(CLR_CMAKE_HOST_OS STREQUAL SunOS)
if(CLR_CMAKE_HOST_OS STREQUAL Windows)
set(CLR_CMAKE_HOST_OS windows)
set(CLR_CMAKE_HOST_WIN32 1)
endif(CLR_CMAKE_HOST_OS STREQUAL Windows)
if(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
set(CLR_CMAKE_HOST_UNIX 1)
set(CLR_CMAKE_HOST_BROWSER 1)
endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
#--------------------------------------------
# This repo builds two set of binaries
# 1. binaries which execute on target arch machine
# - for such binaries host architecture & target architecture are same
# - eg. coreclr.dll
# 2. binaries which execute on host machine but target another architecture
# - host architecture is different from target architecture
# - eg. crossgen.exe - runs on x64 machine and generates nis targeting arm64
# - for complete list of such binaries refer to file crosscomponents.cmake
#-------------------------------------------------------------
# Set HOST architecture variables
if(CLR_CMAKE_HOST_UNIX_ARM)
set(CLR_CMAKE_HOST_ARCH_ARM 1)
set(CLR_CMAKE_HOST_ARCH "arm")
if(CLR_CMAKE_HOST_UNIX_ARMV7L)
set(CLR_CMAKE_HOST_ARCH_ARMV7L 1)
endif()
elseif(CLR_CMAKE_HOST_UNIX_ARM64)
set(CLR_CMAKE_HOST_ARCH_ARM64 1)
set(CLR_CMAKE_HOST_ARCH "arm64")
elseif(CLR_CMAKE_HOST_UNIX_AMD64)
set(CLR_CMAKE_HOST_ARCH_AMD64 1)
set(CLR_CMAKE_HOST_ARCH "x64")
elseif(CLR_CMAKE_HOST_UNIX_X86)
set(CLR_CMAKE_HOST_ARCH_I386 1)
set(CLR_CMAKE_HOST_ARCH "x86")
elseif(CLR_CMAKE_HOST_UNIX_S390X)
set(CLR_CMAKE_HOST_ARCH_S390X 1)
set(CLR_CMAKE_HOST_ARCH "s390x")
elseif(CLR_CMAKE_HOST_BROWSER)
set(CLR_CMAKE_HOST_ARCH_WASM 1)
set(CLR_CMAKE_HOST_ARCH "wasm")
elseif(CLR_CMAKE_HOST_UNIX_MIPS64)
set(CLR_CMAKE_HOST_ARCH_MIPS64 1)
set(CLR_CMAKE_HOST_ARCH "mips64")
elseif(WIN32)
# CLR_CMAKE_HOST_ARCH is passed in as param to cmake
if (CLR_CMAKE_HOST_ARCH STREQUAL x64)
set(CLR_CMAKE_HOST_ARCH_AMD64 1)
elseif(CLR_CMAKE_HOST_ARCH STREQUAL x86)
set(CLR_CMAKE_HOST_ARCH_I386 1)
elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm)
set(CLR_CMAKE_HOST_ARCH_ARM 1)
elseif(CLR_CMAKE_HOST_ARCH STREQUAL arm64)
set(CLR_CMAKE_HOST_ARCH_ARM64 1)
else()
clr_unknown_arch()
endif()
endif()
# Set TARGET architecture variables
# Target arch will be a cmake param (optional) for both windows as well as non-windows build
# if target arch is not specified then host & target are same
if(NOT DEFINED CLR_CMAKE_TARGET_ARCH OR CLR_CMAKE_TARGET_ARCH STREQUAL "" )
set(CLR_CMAKE_TARGET_ARCH ${CLR_CMAKE_HOST_ARCH})
# This is required for "arm" targets (CMAKE_SYSTEM_PROCESSOR "armv7l"),
# for which this flag otherwise won't be set up below
if (CLR_CMAKE_HOST_ARCH_ARMV7L)
set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1)
endif()
endif()
# Set target architecture variables
if (CLR_CMAKE_TARGET_ARCH STREQUAL x64)
set(CLR_CMAKE_TARGET_ARCH_AMD64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
set(CLR_CMAKE_TARGET_ARCH_I386 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
set(CLR_CMAKE_TARGET_ARCH_ARM64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
set(CLR_CMAKE_TARGET_ARCH_ARM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
set(CLR_CMAKE_TARGET_ARCH_ARM 1)
set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1)
set(ARM_SOFTFP 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x)
set(CLR_CMAKE_TARGET_ARCH_S390X 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
set(CLR_CMAKE_TARGET_ARCH_WASM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
set(CLR_CMAKE_TARGET_ARCH_MIPS64 1)
else()
clr_unknown_arch()
endif()
# Set TARGET architecture variables
# Target os will be a cmake param (optional) for both windows as well as non-windows build
# if target os is not specified then host & target os are same
if (NOT DEFINED CLR_CMAKE_TARGET_OS OR CLR_CMAKE_TARGET_OS STREQUAL "" )
set(CLR_CMAKE_TARGET_OS ${CLR_CMAKE_HOST_OS})
endif()
if(CLR_CMAKE_TARGET_OS STREQUAL Linux)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL Linux)
if(CLR_CMAKE_TARGET_OS STREQUAL tizen)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
set(CLR_CMAKE_TARGET_TIZEN_LINUX 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL tizen)
if(CLR_CMAKE_TARGET_OS STREQUAL alpine)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
set(CLR_CMAKE_TARGET_ALPINE_LINUX 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL alpine)
if(CLR_CMAKE_TARGET_OS STREQUAL Android)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
set(CLR_CMAKE_TARGET_ANDROID 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL Android)
if(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
set(CLR_CMAKE_TARGET_UNIX 1)
if(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
set(CLR_CMAKE_TARGET_MACCATALYST 1)
else()
set(CLR_CMAKE_TARGET_OSX 1)
endif(CMAKE_SYSTEM_VARIANT STREQUAL MacCatalyst)
endif(CLR_CMAKE_TARGET_OS STREQUAL Darwin)
if(CLR_CMAKE_TARGET_OS STREQUAL iOS OR CLR_CMAKE_TARGET_OS STREQUAL iOSSimulator)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_IOS 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL iOS OR CLR_CMAKE_TARGET_OS STREQUAL iOSSimulator)
if(CLR_CMAKE_TARGET_OS STREQUAL tvOS OR CLR_CMAKE_TARGET_OS STREQUAL tvOSSimulator)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_TVOS 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL tvOS OR CLR_CMAKE_TARGET_OS STREQUAL tvOSSimulator)
if(CLR_CMAKE_TARGET_OS STREQUAL FreeBSD)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_FREEBSD 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL FreeBSD)
if(CLR_CMAKE_TARGET_OS STREQUAL OpenBSD)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_OPENBSD 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL OpenBSD)
if(CLR_CMAKE_TARGET_OS STREQUAL NetBSD)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_NETBSD 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL NetBSD)
if(CLR_CMAKE_TARGET_OS STREQUAL SunOS)
set(CLR_CMAKE_TARGET_UNIX 1)
if(CLR_CMAKE_HOST_OS_ILLUMOS)
set(CLR_CMAKE_TARGET_OS_ILLUMOS 1)
else(CLR_CMAKE_HOST_OS_ILLUMOS)
set(CLR_CMAKE_TARGET_OS_SOLARIS 1)
endif(CLR_CMAKE_HOST_OS_ILLUMOS)
set(CLR_CMAKE_TARGET_SUNOS 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL SunOS)
if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
set(CLR_CMAKE_TARGET_UNIX 1)
set(CLR_CMAKE_TARGET_LINUX 1)
set(CLR_CMAKE_TARGET_BROWSER 1)
endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
if(CLR_CMAKE_TARGET_UNIX)
if(CLR_CMAKE_TARGET_ARCH STREQUAL x64)
set(CLR_CMAKE_TARGET_UNIX_AMD64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel)
set(CLR_CMAKE_TARGET_UNIX_ARM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm)
set(CLR_CMAKE_TARGET_UNIX_ARM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64)
set(CLR_CMAKE_TARGET_UNIX_ARM64 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86)
set(CLR_CMAKE_TARGET_UNIX_X86 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x)
set(CLR_CMAKE_TARGET_UNIX_S390X 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm)
set(CLR_CMAKE_TARGET_UNIX_WASM 1)
elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64)
set(CLR_CMAKE_TARGET_UNIX_MIPS64 1)
else()
clr_unknown_arch()
endif()
else()
set(CLR_CMAKE_TARGET_WIN32 1)
endif(CLR_CMAKE_TARGET_UNIX)
# check if host & target os/arch combination are valid
if (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)
if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
if(NOT((CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_I386)))
message(FATAL_ERROR "Invalid platform and target arch combination TARGET_ARCH=${CLR_CMAKE_TARGET_ARCH} HOST_ARCH=${CLR_CMAKE_HOST_ARCH}")
endif()
endif()
else()
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
endif()
if(NOT (CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_ALPINE_LINUX))
message(FATAL_ERROR "Invalid host and target os/arch combination. Target OS: ${CLR_CMAKE_TARGET_OS}")
endif()
if(NOT ((CLR_CMAKE_HOST_ARCH_AMD64 AND (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64)) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM)))
message(FATAL_ERROR "Invalid host and target os/arch combination. Host Arch: ${CLR_CMAKE_HOST_ARCH} Target Arch: ${CLR_CMAKE_TARGET_ARCH}")
endif()
endif()
if(NOT CLR_CMAKE_TARGET_BROWSER)
# The default linker on Solaris also does not support PIE.
if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_HOST_TVOS AND NOT CLR_CMAKE_HOST_IOS AND NOT MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
add_compile_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-fPIE>)
add_compile_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:-fPIC>)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE)
if(LOWERCASE_CMAKE_BUILD_TYPE STREQUAL debug)
# Clear _FORTIFY_SOURCE=2, if set
string(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-D_FORTIFY_SOURCE=2 " "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()