-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
226 lines (196 loc) · 7.15 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# (C) 2021 The University of Chicago
# See COPYRIGHT in top-level directory.
cmake_minimum_required (VERSION 3.15)
project (yokan C CXX)
enable_testing ()
# library version set here (e.g. for shared libs).
set (YOKAN_VERSION_MAJOR 0)
set (YOKAN_VERSION_MINOR 8)
set (YOKAN_VERSION_PATCH 0)
set (YOKAN_VERSION
"${YOKAN_VERSION_MAJOR}.${YOKAN_VERSION_MINOR}.${YOKAN_VERSION_PATCH}")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall")
add_library (coverage_config INTERFACE)
option (ENABLE_COVERAGE "Enable coverage reporting" OFF)
option (ENABLE_TESTS "Build tests" OFF)
option (ENABLE_BENCHMARK "Build benchmark" OFF)
option (ENABLE_BEDROCK "Build bedrock module" OFF)
option (ENABLE_LEVELDB "Build with leveldb support" OFF)
option (ENABLE_ROCKSDB "Build with rocksdb support" OFF)
option (ENABLE_BERKELEYDB "Build with berkeleydb support" OFF)
option (ENABLE_TKRZW "Build with tkrzw support" OFF)
option (ENABLE_LMDB "Build with lmdb support" OFF)
option (ENABLE_GDBM "Build with gdbm support" OFF)
option (ENABLE_UNQLITE "Build with unqlite support" OFF)
option (ENABLE_LUA "Build with Lua support" OFF)
option (ENABLE_PYTHON "Build the Python module" OFF)
option (ENABLE_YCSB "Build the YCSB adaptor" OFF)
option (ENABLE_REMI "Build with REMI support" OFF)
if (ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options (coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options (coverage_config INTERFACE --coverage)
else ()
target_link_libraries (coverage_config INTERFACE --coverage)
endif ()
endif ()
# add our cmake module directory to the path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# link shared lib with full rpath
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# setup cache variables for ccmake
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release
CACHE STRING "Choose the type of build." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif ()
set (CMAKE_PREFIX_PATH "" CACHE STRING "External dependencies path")
set (BUILD_SHARED_LIBS "ON" CACHE BOOL "Build a shared library")
find_package (nlohmann_json REQUIRED)
find_package (PkgConfig REQUIRED)
if (${ENABLE_BEDROCK})
find_package (bedrock-module-api REQUIRED)
endif ()
if (${ENABLE_REMI})
find_package (remi REQUIRED)
set (YOKAN_HAS_REMI ON)
else ()
set (YOKAN_HAS_REMI OFF)
endif ()
# search for margo
pkg_check_modules (margo REQUIRED IMPORTED_TARGET margo)
# search for tclap
pkg_check_modules (tclap REQUIRED IMPORTED_TARGET tclap)
set (YOKAN_BACKEND_LIST map;unordered_map;set;unordered_set;array;log)
if (ENABLE_LEVELDB)
pkg_check_modules (leveldb REQUIRED IMPORTED_TARGET leveldb)
set (YOKAN_HAS_LEVELDB ON)
list (APPEND YOKAN_BACKEND_LIST leveldb)
else ()
set (YOKAN_HAS_LEVELDB OFF)
endif ()
if (ENABLE_ROCKSDB)
pkg_check_modules (rocksdb REQUIRED IMPORTED_TARGET rocksdb)
set (YOKAN_HAS_ROCKSDB ON)
list (APPEND YOKAN_BACKEND_LIST rocksdb)
if (${rocksdb_VERSION} VERSION_GREATER_EQUAL 7)
set (CMAKE_CXX_STANDARD 17)
endif ()
else ()
set (YOKAN_HAS_ROCKSDB OFF)
endif ()
if (ENABLE_BERKELEYDB)
find_package (BerkeleyDB REQUIRED)
set (YOKAN_HAS_BERKELEYDB ON)
list (APPEND YOKAN_BACKEND_LIST berkeleydb)
else ()
set (YOKAN_HAS_BERKELEYDB OFF)
endif ()
if (ENABLE_TKRZW)
pkg_check_modules (tkrzw REQUIRED IMPORTED_TARGET tkrzw)
set (YOKAN_HAS_TKRZW ON)
set (CMAKE_CXX_STANDARD 17)
list (APPEND YOKAN_BACKEND_LIST tkrzw)
else ()
set (YOKAN_HAS_TKRZW OFF)
endif ()
if (ENABLE_GDBM)
find_package (GDBM REQUIRED)
list (APPEND YOKAN_BACKEND_LIST gdbm)
set (YOKAN_HAS_GDBM ON)
else ()
set (YOKAN_HAS_GDBM OFF)
endif ()
if (ENABLE_LMDB)
pkg_check_modules (lmdb REQUIRED IMPORTED_TARGET lmdb)
set (YOKAN_HAS_LMDB ON)
list (APPEND YOKAN_BACKEND_LIST lmdb)
else ()
set (YOKAN_HAS_LMDB OFF)
endif ()
if (ENABLE_UNQLITE)
find_package (UnQLite REQUIRED)
set (YOKAN_HAS_UNQLITE ON)
list (APPEND YOKAN_BACKEND_LIST unqlite)
else ()
set (YOKAN_HAS_UNQLITE OFF)
endif ()
if (ENABLE_LUA)
find_package (sol2 REQUIRED)
find_package (Lua REQUIRED)
set (YOKAN_HAS_LUA ON)
set (CMAKE_CXX_STANDARD 17)
else ()
set (YOKAN_HAS_LUA OFF)
endif ()
if (ENABLE_PYTHON)
find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
find_package (pybind11 REQUIRED)
add_subdirectory (python)
endif ()
# Detect std::string_view or std::experimental::string_view
try_compile (HAS_STRING_VIEW ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/cmake-tests/has_string_view.cpp)
if (${HAS_STRING_VIEW})
message (STATUS "Found std::string_view to be available")
add_definitions (-DYOKAN_USE_STD_STRING_VIEW)
else ()
try_compile (HAS_EXP_STRING_VIEW ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/cmake-tests/has_experimental_string_view.cpp)
if (${HAS_EXP_STRING_VIEW})
message (STATUS "Found std::experimental::string_view to be available")
else ()
message (FATAL_ERROR "Yokan needs either std::string_view or std::experimental::string_view")
endif ()
endif ()
# Detect std::string_view or std::experimental::string_view
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0")
set (FS_LIB c++fs)
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (FS_LIB stdc++fs)
endif ()
try_compile (HAS_FILESYSTEM ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/cmake-tests/has_filesystem.cpp
LINK_LIBRARIES ${FS_LIB})
if (${HAS_FILESYSTEM})
message (STATUS "Found std::filesystem to be available")
add_definitions (-DYOKAN_USE_STD_FILESYSTEM)
else ()
try_compile (HAS_EXP_FILESYSTEM ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src/cmake-tests/has_experimental_filesystem.cpp
LINK_LIBRARIES ${FS_LIB})
if (${HAS_EXP_FILESYSTEM})
message (STATUS "Found std::experimental::filesystem to be available")
else ()
message (FATAL_ERROR "Yokan needs either std::filesystem or std::experimental::filesystem")
endif ()
endif ()
if (${ENABLE_BENCHMARK})
add_subdirectory (benchmark)
endif ()
if (${ENABLE_YCSB})
find_package (ycsb-cpp-interface CONFIG REQUIRED)
add_subdirectory (ycsb)
endif ()
add_subdirectory (src)
if (${ENABLE_TESTS})
add_subdirectory (tests)
endif ()
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindBerkeleyDB.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGDBM.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindUnQLite.cmake
DESTINATION share/cmake/yokan)