This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·136 lines (106 loc) · 4.34 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
cmake_minimum_required(VERSION 3.9)
project(shamon LANGUAGES C VERSION 0.1)
enable_testing()
include(ExternalProject)
SET (CMAKE_VERBOSE_MAKEFILE 1)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
OPTION(ENABLE_IPO "Enable interprocedural optimizations" ON)
if (ENABLE_IPO)
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if (NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
message(WARNING "IPO are used, but the compiler is not clang (compiler = ${CMAKE_C_COMPILER_ID})."
"This may cause troubles when using compilation scripts "
"that are not based on cmake (e.g., gen/compile.sh).")
endif()
endif()
endif(ENABLE_IPO)
OPTION(DUMP_STATS "Collect and allow dumping statistics" OFF)
OPTION(DYNAMORIO_SOURCES "Build sources based on DynamoRIO" ON)
OPTION(RMIND_RINGBUF "Build and use githbu:rmind/ringbuf ring buffer" OFF)
OPTION(BPF_SOURCES "Build and use eBPF sources" OFF)
OPTION(LLVM_SOURCES "Build and use LLVM sources" ON)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# Here we can setup the responsivity of buffers:
# If there is no event on a buffer, we first busy wait
# BUSY_WAIT_FOR_EVENTS times. Then we suspend the thread
# for SLEEP_TIME_INIT_NS seconds, then two times longer,
# etc. up the the SLEEP_TIME_THRES_NS. If no event
# still came, we keep suspending the thread using
# the SLEEP_TIME_THRES_NS duration.
add_compile_definitions(BUSY_WAIT_FOR_EVENTS=1000)
add_compile_definitions(SLEEP_TIME_INIT_NS=10)
add_compile_definitions(SLEEP_TIME_THRES_NS=30000)
if (DUMP_STATS)
add_compile_definitions(DUMP_STATS)
endif()
if (RMIND_RINGBUF)
ExternalProject_Add(rmind-ringbuf
GIT_REPOSITORY https://github.com/rmind/ringbuf
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rmind-ringbuf
CONFIGURE_COMMAND ""
BUILD_COMMAND make -C src
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1)
add_compile_definitions(RMIND_RINGBUF)
endif()
if (BPF_SOURCES)
ExternalProject_Add(bcc
GIT_REPOSITORY https://github.com/mchalupa/bcc
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bcc
GIT_TAG readwrite
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1)
add_compile_definitions(BPF_SOURCES)
endif()
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wpedantic -Werror")
add_compile_options(-Wall -Wextra -pedantic)
if (DYNAMORIO_SOURCES)
find_package(DynamoRIO)
if (NOT DynamoRIO_FOUND)
message(FATAL_ERROR
"DynamoRIO package required to build DynamoRIO sources")
endif(NOT DynamoRIO_FOUND)
endif()
add_subdirectory(core)
include_directories(${CMAKE_SOURCE_DIR}/core)
link_directories(${CMAKE_SOURCE_DIR}/core)
add_subdirectory(streams)
add_subdirectory(sources)
add_subdirectory(shmbuf)
add_subdirectory(monitors)
add_subdirectory(experiments)
add_subdirectory(tests)
add_library(shamon-client STATIC core/source.c)
target_link_libraries(shamon-client PUBLIC shamon-shmbuf shamon-utils shamon-event shamon-queue-spsc shamon-vector
shamon-list shamon-string shamon-ringbuf shamon-signature)
set_property(TARGET shamon-client PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(shamon-monitor STATIC core/monitor.c)
target_link_libraries(shamon-monitor PUBLIC shamon-streams shamon-stream shamon-shmbuf shamon-source shamon-arbiter shamon-parallel-queue
shamon-utils shamon-event shamon-queue-spsc shamon-vector
shamon-list shamon-string shamon-ringbuf shamon-signature)
set_property(TARGET shamon-monitor PROPERTY POSITION_INDEPENDENT_CODE 1)
install(EXPORT shamonCore
FILE shamon.cmake
#NAMESPACE shmn::
DESTINATION lib/cmake/shamon)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/shamonConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/shamonConfig.cmake"
INSTALL_DESTINATION "lib/cmake/shamon"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"shamonVersion.cmake"
VERSION ${shamon_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/shamonConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/shamonVersion.cmake"
DESTINATION lib/cmake/shamon)