forked from DataDog/dd-trace-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
110 lines (85 loc) · 3.33 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
cmake_minimum_required (VERSION 3.8..3.19)
cmake_policy(SET CMP0015 NEW)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
# macOS uses 3.30 which deprecates FetchContent_Populate in favor of FetchContent_MakeAvailable,
# but we're using 3.13.4 on Linux, which doesn't have FetchContent_MakeAvailable
if(POLICY CMP0169)
cmake_policy(SET CMP0169 OLD)
endif()
# ******************************************************
# Project definition
# ******************************************************
project("Datadog.APM.Native" VERSION 2.18.0)
# ******************************************************
# Environment detection
# ******************************************************
option(UNIVERSAL "Build as Universal binary" ON)
message(STATUS "Building Native Loader and Wrapper as Universal binary: " ${UNIVERSAL})
if (CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using toolchain file ${CMAKE_TOOLCHAIN_FILE}")
endif()
SET(OSX_ARCH ${CMAKE_OSX_ARCHITECTURES})
# Detect architecture
if (OSX_ARCH STREQUAL x86_64)
message(STATUS "Architecture is x64/AMD64 configured by CMAKE_OSX_ARCHITECTURES")
SET(ISAMD64 true)
elseif (OSX_ARCH STREQUAL arm64)
message(STATUS "Architecture is ARM64 configured by CMAKE_OSX_ARCHITECTURES")
SET(ISARM64 true)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
message(STATUS "Architecture is x64/AMD64")
SET(ISAMD64 true)
SET(OSX_ARCH "x86_64")
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL x86 OR CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
message(STATUS "Architecture is x86")
SET(ISX86 true)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
message(STATUS "Architecture is ARM64")
SET(ISARM64 true)
SET(OSX_ARCH "arm64")
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
message(STATUS "Architecture is ARM")
SET(ISARM true)
endif()
# Detect operating system
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
message(FATAL_ERROR "Windows builds are not supported using CMAKE. Please use Visual Studio")
SET(ISWINDOWS true)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
message(STATUS "Preparing Linux build")
SET(ISLINUX true)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
message(STATUS "Preparing macOS build")
SET(ISMACOS true)
endif()
# Detect bitness of the build
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "Setting compilation for 64bits processor")
SET(BIT64 true)
endif()
SET(DOTNET_TRACER_REPO_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/build/cmake")
find_package(Coreclr REQUIRED)
message(STATUS "Coreclr files ")
find_package(Re2 REQUIRED)
message(STATUS "Re2 library " ${RE2_VERSION})
find_package(Spdlog REQUIRED)
message(STATUS "Spdlog headers")
find_package(ManagedLoader REQUIRED)
message(STATUS "Tracer Managed Loader")
find_package(Libunwind REQUIRED)
message(STATUS "Libunwind library " ${LIBUNWIND_VERSION})
find_package(Libdatadog REQUIRED)
message(STATUS "Libdatadog library " ${LIBDATADOG_VERSION})
find_package(GoogleTest REQUIRED)
message(STATUS "GoogleTest library")
find_package(PPDB REQUIRED)
message(STATUS "PPDB library")
add_subdirectory(tracer)
# profiler cannot be built on MacOS (yet)
if (NOT ISMACOS)
add_subdirectory(profiler)
endif()
add_subdirectory(shared)