forked from eunomia-bpf/bpftime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
115 lines (87 loc) · 2.88 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
cmake_minimum_required(VERSION 3.15)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer")
#
# Project details
#
project(
"bpftime"
VERSION 0.1.0
LANGUAGES C CXX
)
#
# Set project options
#
include(cmake/CompilerWarnings.cmake)
include(cmake/StandardSettings.cmake)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
message(STATUS "Enabling ubsan for Debug builds; Processor=${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm((32.*)|(v6.*)|(v7.*))")
message(STATUS "Linking libatomic on arm32 machines..")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -latomic")
endif()
endif()
message(STATUS "Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION}...\n")
if(UNIX)
add_compile_options("$<$<CONFIG:DEBUG>:-D_DEBUG>") # this will allow to use same _DEBUG macro available in both Linux as well as Windows - MSCV environment. Easy to put Debug specific code.
endif(UNIX)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
#
# Setup alternative names
#
if(${PROJECT_NAME}_USE_ALT_NAMES)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWERCASE)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
else()
set(PROJECT_NAME_LOWERCASE ${PROJECT_NAME})
set(PROJECT_NAME_UPPERCASE ${PROJECT_NAME})
endif()
#
# Prevent building in the source directory
#
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n")
endif()
include(cmake/libbpf.cmake)
# install frida
include(cmake/frida.cmake)
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
if(${ENABLE_EBPF_VERIFIER})
add_subdirectory(bpftime-verifier)
else()
message(STATUS "Skipping ebpf verifier")
# Catch2
add_subdirectory(third_party/Catch2)
endif()
# spdlog
add_subdirectory(third_party/spdlog)
set(SPDLOG_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include)
# argparse
add_subdirectory(third_party/argparse)
# main library
add_subdirectory(vm)
if (BPFTIME_LLVM_JIT)
add_subdirectory(vm/cli)
endif()
add_subdirectory(attach)
add_subdirectory(runtime)
if (${BUILD_BPFTIME_DAEMON})
add_subdirectory(daemon)
endif()
add_subdirectory(tools)
if(${BUILD_ATTACH_IMPL_EXAMPLE})
add_subdirectory(example/attach_implementation)
endif()
# benchmark that requires bpftime libraries
add_subdirectory(benchmark)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
install(TARGETS bpftime-agent bpftime_text_segment_transformer bpftime-syscall-server CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ~/.bpftime)