-
Notifications
You must be signed in to change notification settings - Fork 60
/
CMakeLists.txt
201 lines (180 loc) · 6.36 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
# Copyright 2023 Chengye YU <yuchengye2013 AT outlook.com>.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.10)
project(ycsb-cpp LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Release)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
if(MSVC)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
option(BIND_ROCKSDB "build with rocksdb" OFF)
option(BIND_LMDB "build with lmdb" OFF)
option(BIND_LEVELDB "build with leveldb" OFF)
option(BIND_WIREDTIGER "build with wiredtiger" OFF)
option(WITH_ZLIB "linking YCSB with zlib; needed by HdrHISTOGRAM, DO NOT TURN OFF" ON)
option(WITH_LZ4 "linking YCSB with lz4" OFF)
option(WITH_SNAPPY "linking YCSB with snappy" OFF)
option(WITH_ZSTD "linking YCSB with zstd" OFF)
option(WITH_BZ2 "linking YCSB with bzip2" OFF)
file(GLOB_RECURSE YCSB_CORE_SRC "core/*.cc")
include(FindThreads)
add_executable(ycsb ${YCSB_CORE_SRC})
target_include_directories(ycsb PRIVATE ${PROJECT_SOURCE_DIR})
if (BIND_ROCKSDB)
message(STATUS "BIND_ROCKSDB - ON")
set(WITH_ZLIB ON)
set(WITH_BZ2 ON)
file(GLOB_RECURSE YCSB_ROCKSDB_SRC "rocksdb/*.cc")
target_sources(ycsb PRIVATE ${YCSB_ROCKSDB_SRC})
find_package(RocksDB CONFIG)
if(RocksDB_FOUND)
target_link_libraries(ycsb PRIVATE RocksDB::rocksdb rpcrt4.lib)
else()
message(STATUS "Try to find rocksdb library using find_library")
find_library(ROCKSDB_LIB rocksdb REQUIRED)
find_path(ROCKSDB_INCLUDE_DIR "rocksdb/db.h" REQUIRED)
target_link_libraries(ycsb PRIVATE ${ROCKSDB_LIB})
target_include_directories(ycsb PRIVATE ${ROCKSDB_INCLUDE_DIR})
endif()
message(STATUS "Found RocksDB library")
if(NOT MSVC)
target_link_libraries(ycsb PRIVATE dl)
endif()
else()
message(STATUS "BIND_ROCKSDB - OFF")
endif()
if (BIND_LMDB)
message(STATUS "BIND_LMDB - ON")
file(GLOB_RECURSE YCSB_LMDB_SRC "lmdb/*.cc")
target_sources(ycsb PRIVATE ${YCSB_LMDB_SRC})
find_package(lmdb CONFIG)
if(lmdb_FOUND)
target_link_libraries(ycsb PRIVATE lmdb)
else()
message(STATUS "Try to find lmdb library using find_library")
find_library(LMDB_LIB lmdb REQUIRED)
find_path(LMDB_INCLUDE_DIR "lmdb.h" REQUIRED)
target_link_libraries(ycsb PRIVATE ${LMDB_LIB})
target_include_directories(ycsb PRIVATE ${LMDB_INCLUDE_DIR})
endif()
message(STATUS "Found LMDB library")
else()
message(STATUS "BIND_LMDB - OFF")
endif()
if (BIND_LEVELDB)
message(STATUS "BIND_LEVELDB - ON")
file(GLOB_RECURSE YCSB_LEVELDB_SRC "leveldb/*.cc")
target_sources(ycsb PRIVATE ${YCSB_LEVELDB_SRC})
find_package(leveldb CONFIG)
if(leveldb_FOUND)
target_link_libraries(ycsb PRIVATE leveldb::leveldb)
else()
message(STATUS "Try to find leveldb library using find_library")
find_library(LEVELDB_LIB leveldb REQUIRED)
find_path(LEVELDB_INCLUDE_DIR "leveldb/db.h" REQUIRED)
target_link_libraries(ycsb PRIVATE ${LEVELDB_LIB})
target_include_directories(ycsb PRIVATE ${LEVELDB_INCLUDE_DIR})
endif()
message(STATUS "Found leveldb library")
else()
message(STATUS "BIND_LEVELDB - OFF")
endif ()
if (BIND_WIREDTIGER)
message(STATUS "BIND_WIREDTIGER - ON")
file(GLOB_RECURSE YCSB_WT_SRC "wiredtiger/*.cc")
target_sources(ycsb PRIVATE ${YCSB_WT_SRC})
find_library(WIREDTIGER_LIB wiredtiger REQUIRED)
find_path(WIREDTIGER_INCLUDE_DIR "wiredtiger.h" REQUIRED)
target_link_libraries(ycsb PRIVATE ${WIREDTIGER_LIB})
target_include_directories(ycsb PRIVATE ${WIREDTIGER_INCLUDE_DIR})
else()
message(STATUS "BIND_WIREDTIGER - OFF")
endif()
if(WITH_ZLIB)
message(STATUS "WITH_ZLIB - ON")
find_package(ZLIB)
if(ZLIB_FOUND)
target_link_libraries(ycsb PRIVATE ZLIB::ZLIB)
else()
message(STATUS "Try to find zlib library using find_library")
find_library(ZLIB_LIB zlib)
if(ZLIB_LIB-NOTFOUND)
find_library(ZLIB_LIB z REQUIRED)
endif()
target_link_libraries(ycsb PRIVATE ${ZLIB_LIB})
endif()
message(STATUS "Found ZLIB library")
else()
message(STATUS "WITH_ZLIB - OFF")
endif()
if(WITH_SNAPPY)
message(STATUS "WITH_SNAPPY - ON")
find_package(Snappy CONFIG)
if(Snappy_FOUND)
target_link_libraries(ycsb PRIVATE Snappy::snappy)
else()
message(STATUS "Try to find Snappy library using find_library")
find_library(SNAPPY_LIB snappy REQUIRED)
target_link_libraries(ycsb PRIVATE ${SNAPPY_LIB})
endif()
message(STATUS "Found Snappy library")
else()
message(STATUS "WITH_SNAPPY - OFF")
endif()
if(WITH_LZ4)
message(STATUS "WITH_LZ4 - ON")
find_package(lz4 CONFIG)
if(lz4_FOUND)
target_link_libraries(ycsb PRIVATE lz4::lz4)
else()
message(STATUS "Try to find LZ4 library using find_library")
find_library(LZ4_LIB lz4 REQUIRED)
target_link_libraries(ycsb PRIVATE ${LZ4_LIB})
endif()
message(STATUS "Found LZ4 library")
else()
message(STATUS "WITH_LZ4 - OFF")
endif()
if(WITH_ZSTD)
message(STATUS "WITH_ZSTD - ON")
find_package(zstd CONFIG)
if(zstd_FOUND)
target_link_libraries(ycsb PRIVATE $<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>)
else()
message(STATUS "Try to find zstd library using find_library")
find_library(ZSTD_LIB zstd REQUIRED)
target_link_libraries(ycsb PRIVATE ${ZSTD_LIB})
endif()
message(STATUS "Found zstd library")
else()
message(STATUS "WITH_ZSTD - OFF")
endif()
if(WITH_BZ2)
message(STATUS "WITH_BZ2 - ON")
find_package(BZip2)
if(BZip2_FOUND)
target_link_libraries(ycsb PRIVATE BZip2::BZip2)
else()
message(STATUS "Try to find BZip2 library using find_library")
find_library(BZ2_LIB bz2 REQUIRED)
target_link_libraries(ycsb PRIVATE ${BZ2_LIB})
endif()
message(STATUS "Found BZip2 library")
else()
message(STATUS "WITH_BZ2 - OFF")
endif()
add_subdirectory(HdrHistogram_c)
include_directories(HdrHistogram_c/include)
add_compile_definitions(HDRMEASUREMENT)
add_dependencies(ycsb hdr_histogram_static)
target_link_libraries(ycsb PRIVATE hdr_histogram_static)