1
1
cmake_minimum_required (VERSION 2.8.12.2)
2
2
3
+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
4
+ # On OSX, we use the libunwind that's part of the OS
5
+ set (CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1)
6
+ endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
7
+
3
8
include_directories (SYSTEM /usr/local/include )
4
- include_directories (libunwind/include )
5
9
6
10
add_compile_options (-fPIC)
7
11
8
- if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
12
+ if (NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
13
+ include_directories (libunwind/include )
9
14
add_subdirectory (libunwind)
10
- endif (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin )
15
+ endif (NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND )
11
16
12
17
include (configure.cmake)
13
18
@@ -240,10 +245,9 @@ set(SOURCES
240
245
thread/tls.cpp
241
246
)
242
247
243
- if (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
244
- # On OSX, we use the libunwind that's part of the OS
248
+ if (NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
245
249
set (LIBUNWIND_OBJECTS $<TARGET_OBJECTS:libunwind>)
246
- endif (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin )
250
+ endif (NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND )
247
251
248
252
add_library (coreclrpal
249
253
STATIC
@@ -267,10 +271,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
267
271
endif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
268
272
269
273
if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
274
+ if (CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
275
+ find_library (UNWIND unwind)
276
+ endif ()
270
277
find_library (INTL intl)
271
278
target_link_libraries (coreclrpal
272
279
pthread
273
280
rt
281
+ ${UNWIND}
274
282
${INTL}
275
283
)
276
284
endif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
@@ -303,7 +311,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
303
311
${LZMA} )
304
312
endif ()
305
313
306
-
307
314
if (CLR_MAKE_PLATFORM_ANDROID)
308
315
find_library (ANDROID_SUPPORT NAMES android-support)
309
316
find_library (ANDROID_GLOB NAMES android-glob)
@@ -326,20 +333,56 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
326
333
dl
327
334
)
328
335
329
-
330
336
if (NOT INTL STREQUAL INTL-NOTFOUND )
331
337
target_link_libraries (coreclrpal ${INTL} )
332
338
endif (NOT INTL STREQUAL INTL-NOTFOUND )
333
339
340
+ if (CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
341
+ if (PAL_CMAKE_PLATFORM_ARCH_ARM)
342
+ find_library (UNWIND_ARCH NAMES unwind-arm)
343
+ endif ()
344
+
345
+ if (PAL_CMAKE_PLATFORM_ARCH_ARM64)
346
+ find_library (UNWIND_ARCH NAMES unwind-aarch64)
347
+ endif ()
348
+
349
+ if (PAL_CMAKE_PLATFORM_ARCH_AMD64)
350
+ find_library (UNWIND_ARCH NAMES unwind-x86_64)
351
+ endif ()
352
+
353
+ if (NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND )
354
+ target_link_libraries (coreclrpal ${UNWIND_ARCH} )
355
+ endif ()
356
+
357
+ find_library (UNWIND_GENERIC NAMES unwind-generic)
358
+
359
+ if (NOT UNWIND_GENERIC STREQUAL UNWIND_GENERIC-NOTFOUND )
360
+ target_link_libraries (coreclrpal ${UNWIND_GENERIC} )
361
+ endif ()
362
+
363
+ find_library (UNWIND NAMES unwind)
364
+
365
+ if (UNWIND STREQUAL UNWIND-NOTFOUND )
366
+ message (FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev or libunwind-devel." )
367
+ endif ()
368
+
369
+ target_link_libraries (coreclrpal ${UNWIND} )
370
+
371
+ endif (CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
372
+
334
373
endif (CMAKE_SYSTEM_NAME STREQUAL Linux)
335
374
336
375
if (CMAKE_SYSTEM_NAME STREQUAL NetBSD)
376
+ if (CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
377
+ find_library (UNWIND unwind)
378
+ endif ()
337
379
add_definitions (-D_KMEMUSER)
338
380
find_library (INTL intl)
339
381
find_library (KVM kvm)
340
382
target_link_libraries (coreclrpal
341
383
pthread
342
384
rt
385
+ ${UNWIND}
343
386
${INTL}
344
387
${KVM}
345
388
)
0 commit comments