-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
212 lines (188 loc) · 7.49 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
cmake_minimum_required(VERSION 3.19)
include(FetchContent)
project(serverless-rdma)
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined")
#set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined")
#find_program(CLANG_TIDY_COMMAND NAMES clang-tidy clang-tidy-13 clang-tidy-12 clang-tidy-11 clang-tidy-10)
#if(NOT CLANG_TIDY_COMMAND)
# message(WARNING "clang-tidy is not found!")
# set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
#else()
# set(CLANG_TIDY_CHECKS "*")
# set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND};-checks=${CLANG_TIDY_CHECKS};-header-filter=.")
#endif()
# dirty hack to remove NDEBUG
string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -g -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG ")
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra ")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/configuration)
option(WITH_EXAMPLES "Enable building extended function examples (requires additional dependencies)." Off)
if(${WITH_EXAMPLES})
set(RFAAS_WITH_EXAMPLES ON)
else()
set(RFAAS_WITH_EXAMPLES OFF)
endif()
set(WITH_TESTING "" CACHE STRING "Enable building of rFaaS tests, using the testing specification provided in JSON file.")
if( NOT WITH_TESTING STREQUAL "" )
set(TESTING_CONFIG ${WITH_TESTING})
set(RFAAS_WITH_TESTING ON)
if(NOT EXISTS ${TESTING_CONFIG})
message(FATAL_ERROR "The provided file does not exist: ${TESTING_CONFIG}!")
endif()
file(COPY ${TESTING_CONFIG} DESTINATION ${CMAKE_BINARY_DIR}/tests/configuration)
message(STATUS "Enabling testing using configuration provided with ${TESTING_CONFIG}")
else()
set(RFAAS_WITH_TESTING OFF)
endif()
###
# Optional: use existing installations
###
set(CXXOPTS_PATH "" CACHE STRING "Path to installation of cxxopts")
if( NOT CXXOPTS_PATH STREQUAL "")
set(cxxopts_DIR "${CXXOPTS_PATH}/lib/cmake/cxxopts")
endif()
set(SPDLOG_PATH "" CACHE STRING "Path to installation of spdlog")
if( NOT SPDLOG_PATH STREQUAL "")
set(spdlog_DIR "${SPDLOG_PATH}/lib/cmake/spdlog")
endif()
set(LIBRDMACM_PATH "" CACHE STRING "Path to installation of librdmacm")
if( NOT LIBRDMACM_PATH STREQUAL "")
set(PKG_CONFIG_PATH "${PKG_CONFIG_PATH} ${LIBRDMACM_PATH}/lib/pkgconfig")
endif()
###
# threads
###
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
###
# PkgConfig
###
find_package(PkgConfig REQUIRED)
if (NOT PkgConfig_FOUND)
message(FATAL_ERROR "PkgConfig library not found")
endif (NOT PkgConfig_FOUND)
###
# librdmacm
###
pkg_check_modules(rdmacm REQUIRED IMPORTED_TARGET librdmacm)
###
# libibverbs
###
pkg_check_modules(ibverbs REQUIRED IMPORTED_TARGET libibverbs)
###
# pistache
###
pkg_check_modules(Pistache REQUIRED IMPORTED_TARGET libpistache)
###
# External dependencies
###
include(dependencies)
###
# rdmalib: build C++14, PIC and no RTTI
###
file(GLOB rdmalib_files "rdmalib/lib/*.cpp")
add_library(rdmalib STATIC ${rdmalib_files})
add_dependencies(rdmalib spdlog)
add_dependencies(rdmalib cereal)
target_include_directories(rdmalib PUBLIC "rdmalib/include")
target_include_directories(rdmalib SYSTEM PUBLIC $<TARGET_PROPERTY:PkgConfig::rdmacm,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(rdmalib SYSTEM PUBLIC $<TARGET_PROPERTY:PkgConfig::ibverbs,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(rdmalib SYSTEM PUBLIC $<TARGET_PROPERTY:cereal,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(rdmalib SYSTEM PRIVATE $<TARGET_PROPERTY:spdlog::spdlog,INTERFACE_INCLUDE_DIRECTORIES>)
set_target_properties(rdmalib PROPERTIES POSITION_INDEPENDENT_CODE On)
set_target_properties(rdmalib PROPERTIES LIBRARY_OUTPUT_DIRECTORY lib)
target_link_libraries(rdmalib PUBLIC PkgConfig::rdmacm)
target_link_libraries(rdmalib PUBLIC PkgConfig::ibverbs)
target_link_libraries(rdmalib PRIVATE spdlog::spdlog)
target_link_libraries(rdmalib PRIVATE cereal)
###
# client library
###
file(GLOB rdmalib_files "rfaas/lib/*.cpp")
add_library(rfaaslib STATIC ${rdmalib_files})
add_dependencies(rfaaslib spdlog)
add_dependencies(rfaaslib cereal)
add_dependencies(rfaaslib rdmalib)
target_include_directories(rfaaslib PUBLIC "rfaas/include")
target_include_directories(rfaaslib PRIVATE $<TARGET_PROPERTY:rdmalib,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(rfaaslib SYSTEM PUBLIC $<TARGET_PROPERTY:cereal,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(rfaaslib SYSTEM PUBLIC $<TARGET_PROPERTY:spdlog::spdlog,INTERFACE_INCLUDE_DIRECTORIES>)
set_target_properties(rfaaslib PROPERTIES POSITION_INDEPENDENT_CODE On)
set_target_properties(rfaaslib PROPERTIES LIBRARY_OUTPUT_DIRECTORY lib)
target_link_libraries(rfaaslib PUBLIC rdmalib)
target_link_libraries(rfaaslib PUBLIC PkgConfig::rdmacm)
target_link_libraries(rfaaslib PUBLIC PkgConfig::ibverbs)
target_link_libraries(rfaaslib PUBLIC spdlog::spdlog)
target_link_libraries(rfaaslib PRIVATE cereal)
target_link_libraries(rfaaslib PUBLIC dl)
target_link_libraries(rfaaslib PUBLIC Threads::Threads)
###
# Server
###
add_executable(executor
server/executor/cli.cpp
server/executor/opts.cpp
server/executor/fast_executor.cpp
server/executor/functions.cpp
)
add_executable(executor_manager
server/executor_manager/cli.cpp
server/executor_manager/opts.cpp
server/executor_manager/settings.cpp
server/executor_manager/manager.cpp
server/executor_manager/client.cpp
server/executor_manager/executor_process.cpp
)
add_executable(resource_manager
server/resource_manager/cli.cpp
server/resource_manager/client.cpp
server/resource_manager/executor.cpp
server/resource_manager/opts.cpp
server/resource_manager/db.cpp
server/resource_manager/http.cpp
server/resource_manager/settings.cpp
server/resource_manager/manager.cpp
)
set(targets "executor" "executor_manager" "resource_manager")
foreach(target ${targets})
add_dependencies(${target} cxxopts::cxxopts)
add_dependencies(${target} spdlog::spdlog)
add_dependencies(${target} rdmalib)
add_dependencies(${target} rfaaslib)
target_include_directories(${target} PRIVATE server/)
target_include_directories(${target} PRIVATE $<TARGET_PROPERTY:rfaaslib,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${target} PRIVATE $<TARGET_PROPERTY:rdmalib,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${target} SYSTEM PRIVATE $<TARGET_PROPERTY:cxxopts::cxxopts,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(${target} PRIVATE spdlog::spdlog)
target_link_libraries(${target} PRIVATE rdmalib)
target_link_libraries(${target} PRIVATE rfaaslib)
target_link_libraries(${target} PRIVATE Threads::Threads)
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin)
endforeach()
target_link_libraries(executor PRIVATE dl)
target_include_directories(resource_manager SYSTEM PUBLIC $<TARGET_PROPERTY:PkgConfig::Pistache,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(resource_manager PRIVATE PkgConfig::Pistache)
###
# Benchmark apps
###
include(benchmarks)
###
# Examples
###
add_library(functions SHARED examples/functions.cpp)
set_target_properties(functions PROPERTIES POSITION_INDEPENDENT_CODE On)
set_target_properties(functions PROPERTIES LIBRARY_OUTPUT_DIRECTORY examples)
if( ${RFAAS_WITH_EXAMPLES} )
include(examples)
endif()
###
# Examples
###
if( ${RFAAS_WITH_TESTING} )
include(testing)
endif()