forked from dotnet/diagnostics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
186 lines (161 loc) · 5.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
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Verify minimum required version
cmake_minimum_required(VERSION 3.6.2)
if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0)
cmake_policy(SET CMP0042 NEW)
endif()
# Set the project name
project(diagnostics)
# include shared compiler configs
include(eng/native/configurepaths.cmake)
include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake)
# override some global configs
if (MSVC)
add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/EHsc>)
add_compile_options($<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
add_compile_options($<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
else (MSVC)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-unused-variable)
add_compile_options(-Wno-implicit-fallthrough)
add_compile_options(-fvisibility=default)
endif (MSVC)
# Register the default component
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME diagnostics)
add_component(diagnostics)
if (WIN32)
message(STATUS "VS_PLATFORM_TOOLSET is ${CMAKE_VS_PLATFORM_TOOLSET}")
message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}")
endif (WIN32)
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (NOT WIN32)
# Drop the static scope for SOS, so it's available outside the
# compilation unit for external linkage; see extern declaration
# in SOS sources.
file(READ "${VERSION_FILE_PATH}" VERSION_FILE_CONTENTS)
string(REPLACE "static char" "char" VERSION_LINE_WITHOUT_STATIC "${VERSION_FILE_CONTENTS}")
file(WRITE "${VERSION_FILE_PATH}" "${VERSION_LINE_WITHOUT_STATIC}")
endif (NOT WIN32)
# Where _version.h for Windows is generated
if (WIN32)
include_directories(${CLR_ARTIFACTS_OBJ_DIR})
endif (WIN32)
set(CORECLR_SET_RPATH ON)
if(CORECLR_SET_RPATH)
# Enable @rpath support for shared libraries.
set(MACOSX_RPATH ON)
endif(CORECLR_SET_RPATH)
OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
OPTION(CLR_CMAKE_WARNINGS_ARE_ERRORS "Warnings are errors" ON)
#------------------------------------
# Definitions (for platform)
#-----------------------------------
if (CLR_CMAKE_HOST_ARCH_AMD64)
add_definitions(-D_AMD64_)
add_definitions(-D_WIN64)
add_definitions(-DAMD64)
add_definitions(-DBIT64=1)
elseif (CLR_CMAKE_HOST_ARCH_I386)
add_definitions(-D_X86_)
elseif (CLR_CMAKE_HOST_ARCH_ARM)
add_definitions(-D_ARM_)
add_definitions(-DARM)
elseif (CLR_CMAKE_HOST_ARCH_ARM64)
add_definitions(-D_ARM64_)
add_definitions(-DARM64)
add_definitions(-D_WIN64)
add_definitions(-DBIT64=1)
elseif (CLR_CMAKE_HOST_ARCH_MIPS64)
add_definitions(-D_MIPS64_)
add_definitions(-DMIPS64)
add_definitions(-D_WIN64)
add_definitions(-DBIT64=1)
else ()
clr_unknown_arch()
endif ()
if (CLR_CMAKE_TARGET_ARCH_AMD64)
if (CLR_CMAKE_HOST_UNIX)
add_definitions(-DDBG_TARGET_AMD64_UNIX)
endif()
add_definitions(-D_TARGET_64BIT_=1)
add_definitions(-D_TARGET_AMD64_=1)
add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_AMD64=1)
add_definitions(-DDBG_TARGET_WIN64=1)
elseif (CLR_CMAKE_TARGET_ARCH_ARM64)
if (CLR_CMAKE_HOST_UNIX)
add_definitions(-DDBG_TARGET_ARM64_UNIX)
endif()
add_definitions(-D_TARGET_ARM64_=1)
add_definitions(-D_TARGET_64BIT_=1)
add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_ARM64=1)
add_definitions(-DDBG_TARGET_WIN64=1)
add_definitions(-DFEATURE_MULTIREG_RETURN)
elseif (CLR_CMAKE_TARGET_ARCH_ARM)
if (CLR_CMAKE_HOST_UNIX)
add_definitions(-DDBG_TARGET_ARM_UNIX)
elseif (WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
# Set this to ensure we can use Arm SDK for Desktop binary linkage when doing native (Arm32) build
add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1)
add_definitions(-D_ARM_WORKAROUND_)
endif (CLR_CMAKE_HOST_UNIX)
add_definitions(-D_TARGET_ARM_=1)
add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_ARM=1)
elseif (CLR_CMAKE_TARGET_ARCH_I386)
add_definitions(-D_TARGET_X86_=1)
add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_32BIT=1)
add_definitions(-DDBG_TARGET_X86=1)
elseif (CLR_CMAKE_TARGET_ARCH_MIPS64)
add_definitions(-DDBG_TARGET_MIPS64_UNIX)
add_definitions(-D_TARGET_MIPS64_=1)
add_definitions(-D_TARGET_64BIT_=1)
add_definitions(-DDBG_TARGET_MIPS64=1)
add_definitions(-DDBG_TARGET_64BIT=1)
add_definitions(-DDBG_TARGET_WIN64=1)
add_definitions(-DFEATURE_MULTIREG_RETURN)
else ()
clr_unknown_arch()
endif (CLR_CMAKE_TARGET_ARCH_AMD64)
if(WIN32)
add_definitions(-DWIN32)
add_definitions(-D_WIN32)
add_definitions(-DWINVER=0x0602)
add_definitions(-D_WIN32_WINNT=0x0602)
add_definitions(-DWIN32_LEAN_AND_MEAN=1)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(WIN32)
#--------------------------------------
# FEATURE Defines
#--------------------------------------
add_definitions(-DFEATURE_CORESYSTEM)
if(CLR_CMAKE_HOST_UNIX)
add_definitions(-DPLATFORM_UNIX=1)
add_definitions(-DFEATURE_PAL)
add_definitions(-DFEATURE_PAL_ANSI)
endif(CLR_CMAKE_HOST_UNIX)
if(WIN32)
add_definitions(-DFEATURE_COMINTEROP)
endif(WIN32)
if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
add_definitions(-DFEATURE_HIJACK)
endif(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
if(FEATURE_EVENT_TRACE)
add_definitions(-DFEATURE_EVENT_TRACE=1)
add_definitions(-DFEATURE_PERFTRACING=1)
endif(FEATURE_EVENT_TRACE)
if(CLR_CMAKE_HOST_UNIX_AMD64)
add_definitions(-DFEATURE_MULTIREG_RETURN)
endif (CLR_CMAKE_HOST_UNIX_AMD64)
if(CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
add_definitions(-DUNIX_AMD64_ABI)
endif(CLR_CMAKE_HOST_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64)
#-----------------------------------------
# Native Projects
#-----------------------------------------
add_subdirectory(src)