-
Notifications
You must be signed in to change notification settings - Fork 47
/
CMakeLists.txt
190 lines (164 loc) · 6.04 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
cmake_minimum_required(VERSION 3.15.4...3.22)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(derecho CXX)
# Version
set(derecho_VERSION 2.4)
set(derecho_build_VERSION 2.4.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDERECHO_DEBUG -O0 -Wall -ggdb -gdwarf-3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
set(CMAKE_CXX_FLAGS_BENCHMARK "${CMAKE_CXX_FLAGS_RELEASE} -Wall -DNOLOG -Ofast -march=native")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wall -ggdb -gdwarf-3")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
include(GNUInstallDirs)
# Prevent "make install" from automatically calling "make all", since the "all" target includes
# all the applications and they are not part of the library we want to install with "make install"
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
include(GetGitRevisionDescription)
# These packages export their location information in the "old" way,
# with INCLUDE_DIRS and LIBRARIES variables
# libfabric_FOUND
# libfabric_INCLUDE_DIRS
# libfabric_LIBRARIES
find_package(libfabric 1.12.1 REQUIRED)
if(${libfabric_FOUND})
include_directories(${libfabric_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Required library LibFabric not found")
endif()
# These packages export their location information in the "new" way,
# by providing an IMPORT-type CMake target that you can use as a
# dependency. Placing this target in target_link_libraries will
# automatically ensure its headers are included.
# Target: mutils::mutils
find_package(mutils REQUIRED)
# Target: mutils::mutils-containers
find_package(mutils-containers REQUIRED)
# Target: spdlog::spdlog
find_package(spdlog 1.12.0 REQUIRED)
# Target: OpenSSL::Crypto and OpenSSL::ssl
find_package(OpenSSL 1.1.1 REQUIRED)
# Target: nlohmann_json::nlohmann_json
find_package(nlohmann_json 3.9.0 REQUIRED)
# Target: Doxygen
find_package(Doxygen)
# Source code configurations go to config.h
# Shift to verbs API. We use libfabric by default.
if (${USE_VERBS_API})
set(USE_VERBS_API 1)
else()
set(USE_VERBS_API 0)
endif()
# Enable High memory registration (for device memory like GPU memory.)
# Important: this does not work with libfabric provider like tcp and socket because they cannot
# RDMA to device memory.
if (${ENABLE_HMEM})
set(ENABLE_HMEM 1)
else()
set(ENABLE_HMEM 0)
endif()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/derecho/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
add_subdirectory(src/mutils-serialization)
add_subdirectory(src/conf)
add_subdirectory(src/utils)
add_subdirectory(src/core)
add_subdirectory(src/rdmc)
add_subdirectory(src/sst)
add_subdirectory(src/tcp)
add_subdirectory(src/persistent)
add_subdirectory(src/openssl)
# make libderecho.so
add_library(derecho SHARED
$<TARGET_OBJECTS:mutils-serialization>
$<TARGET_OBJECTS:conf>
$<TARGET_OBJECTS:utils>
$<TARGET_OBJECTS:core>
$<TARGET_OBJECTS:rdmc>
$<TARGET_OBJECTS:sst>
$<TARGET_OBJECTS:tcp>
$<TARGET_OBJECTS:persistent>
$<TARGET_OBJECTS:openssl_wrapper>)
if (${USE_VERBS_API})
target_link_libraries(derecho
rdmacm ibverbs rt pthread atomic stdc++fs
spdlog::spdlog
${libfabric_LIBRARIES}
mutils::mutils
mutils::mutils-containers
OpenSSL::Crypto
nlohmann_json::nlohmann_json)
else()
target_link_libraries(derecho
rt pthread atomic stdc++fs
spdlog::spdlog
${libfabric_LIBRARIES}
mutils::mutils
mutils::mutils-containers
OpenSSL::Crypto
nlohmann_json::nlohmann_json)
endif()
set_target_properties(derecho PROPERTIES
SOVERSION ${derecho_VERSION}
VERSION ${derecho_build_VERSION}
)
add_dependencies(derecho
mutils-serialization conf utils core
rdmc sst tcp persistent openssl_wrapper)
# Setup for make install
# Declare that we will install the targets built by "derecho"
install(TARGETS derecho EXPORT derechoTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Declare that we will install the "include/" directory as a standard include directory
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/include/derecho
${CMAKE_CURRENT_BINARY_DIR}/include/derecho
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Use CMakePackageConfigHelpers to create a package version file and config file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake/derechoConfigVersion.cmake"
VERSION ${derecho_VERSION}
COMPATIBILITY AnyNewerVersion
)
# The directory where all the derecho*.cmake files will be installed
# The standard is <libDir>/cmake/<packageName>
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/derecho)
configure_package_config_file(derechoConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cmake/derechoConfig.cmake"
INSTALL_DESTINATION ${ConfigPackageLocation}
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)
# Create a CMake targets file for Derecho so it can be imported as a CMake package
install(EXPORT derechoTargets
FILE derechoTargets.cmake
NAMESPACE derecho::
DESTINATION ${ConfigPackageLocation}
)
# Declare that we will install the cmake files that CmakePackageConfigHelpers just created
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/derechoConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/derechoConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
)
# Build applications
add_subdirectory(src/applications)
set (DOXYGEN_EXCLUDE src/applications include/derecho/conf/getpot src/mutils-serialization include/derecho/rdmc src/core/rdmc)
set (DOXYGEN_PROJECT_NUMBER ${derecho_VERSION})
set (DOXYGEN_TAB_SIZE 4)
set (DOXYGEN_WARNINGS NO)
set (DOXYGEN_WARN_IF_UNDOCUMENTED NO)
set (DOXYGEN_WARN_NO_PARAMDOC NO)
if (DOXYGEN_FOUND)
# create docs
doxygen_add_docs(docs
${CMAKE_SOURCE_DIR}/README.md
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src
ALL
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()