blob: 0b36d58d26c87ffcb63f5b90323d1af72240f5dc (
plain)
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
|
project(libunwind)
cmake_minimum_required(VERSION 3.16.1)
set(PKG_MAJOR "1")
set(PKG_MINOR "6")
set(PKG_EXTRA "-rc1")
set(PACKAGE_STRING "libunwind")
set(PACKAGE_BUGREPORT "")
if ('$ENV{TARGET}' STREQUAL 'x86_64-linux-gnu')
set(TARGET_AMD64 1)
set(arch x86_64)
add_definitions(-D__x86_64__)
add_definitions(-D__amd64__)
add_definitions(-D__linux__)
elseif ('$ENV{TARGET}' STREQUAL 'aarch64-linux-gnu')
set(TARGET_AARCH64 1)
set(arch aarch64)
add_definitions(-D__aarch64__)
add_definitions(-D__linux__)
elseif ('$ENV{TARGET}' STREQUAL 'arm-linux-gnueabihf')
set(TARGET_ARM 1)
set(arch arm)
add_definitions(-D__arm__)
add_definitions(-D__linux__)
elseif ('$ENV{TARGET}' STREQUAL 's390x-linux-gnu')
set(TARGET_S390X 1)
set(arch s390x)
add_definitions(-D__s390x__)
add_definitions(-D__linux__)
else ()
message(FATAL_ERROR "Unrecognize value in environment variable TARGET")
endif ()
include(CheckCSourceCompiles)
include(CheckIncludeFiles)
if ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*$")
message(VERBOSE "Using generator ${CMAKE_GENERATOR}")
# Assume we are using default MSVC compiler
add_compile_options(/std:c++latest)
add_compile_options(/TC) # compile all files as C
add_compile_options(/permissive-)
# files for cross os compilation
include_directories(include/win)
# Warnings in release builds
add_compile_options(-wd4068) # ignore unknown pragma warnings (gcc pragmas)
add_compile_options(-wd4146) # minus operator applied to unsigned
add_compile_options(-wd4244) # possible loss of data
add_compile_options(-wd4267) # possible loss of data
add_compile_options(-wd4334) # 32-bit shift implicitly converted to 64 bits
# Disable warning due to incorrect format specifier in debugging printf via the Debug macro
add_compile_options(-wd4311) # pointer truncation from 'unw_word_t *' to 'long'
add_compile_options(-wd4475) # 'fprintf' : length modifier 'L' cannot be used
add_compile_options(-wd4477) # fprintf argument type
# Windows builds will only support remote unwind
add_definitions(-DUNW_REMOTE_ONLY)
# Disable security warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Our posix abstraction layer will provide these headers
set(HAVE_ELF_H 1)
set(HAVE_ENDIAN_H 1)
# MSVC compiler is currently missing C11 stdalign.h header
# Fake it until support is added
check_include_files(stdalign.h HAVE_STDALIGN_H)
if (NOT HAVE_STDALIGN_H)
configure_file(include/win/fakestdalign.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdalign.h)
endif (NOT HAVE_STDALIGN_H)
# MSVC compiler is currently missing C11 stdatomic.h header
# Fake it until support is added
check_include_files(stdatomic.h HAVE_STDATOMIC_H)
if (NOT HAVE_STDATOMIC_H)
configure_file(include/win/fakestdatomic.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/stdatomic.h)
endif (NOT HAVE_STDATOMIC_H)
# MSVC compiler is currently missing C11 _Thread_local
check_c_source_compiles("void main() { _Thread_local int a; }" HAVE_THREAD_LOCAL)
if (NOT HAVE_THREAD_LOCAL)
add_definitions(-D_Thread_local=)
endif (NOT HAVE_THREAD_LOCAL)
else ()
message(FATAL_ERROR "This CMake file is currently only designed for building on Visual Studio")
endif ()
add_definitions(-DHAVE_CONFIG_H)
configure_file(include/config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h)
configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind.h)
configure_file(include/tdep/libunwind_i.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/tdep/libunwind_i.h)
add_subdirectory(src)
|