-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
249 lines (152 loc) · 7.25 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(MICA)
SET(CMAKE_CXX_COMPILER g++-5)
SET(CMAKE_C_LINK_EXECUTABLE g++-5)
OPTION(DEBUG "Enable debugging" OFF)
OPTION(LTO "Use link time optimization" OFF)
# OPTION(AVX2 "Enable AVX2" ON)
OPTION(DPDK "Enable Intel DPDK" ON)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
ADD_DEFINITIONS(-std=c++14)
ADD_DEFINITIONS(-Wall -Wextra)
ADD_DEFINITIONS(-Wzero-as-null-pointer-constant)
ADD_DEFINITIONS(-Wsign-conversion)
ADD_DEFINITIONS(-Wconversion)
ADD_DEFINITIONS(-Winline)
ADD_DEFINITIONS(-Wno-unused-function)
ADD_DEFINITIONS(-march=native)
ADD_DEFINITIONS(-pthread)
ADD_DEFINITIONS(-g)
IF(DEBUG)
MESSAGE(WARNING "Debugging is ENABLED (to disable, run `cmake .. -DDEBUG=OFF`). Performance will be low.")
ADD_DEFINITIONS(-Og)
# ADD_DEFINITIONS(-O0)
ELSE(DEBUG)
MESSAGE(STATUS "Debugging is disabled (to enable, run `cmake .. -DDEBUG=ON`)")
ADD_DEFINITIONS(-DNDEBUG)
ADD_DEFINITIONS(-O3)
# ADD_DEFINITIONS(--param inline-unit-growth=200 --param large-function-growth=500)
ENDIF(DEBUG)
IF(LTO)
MESSAGE(STATUS "Link time optimization is enabled (to disable, run `cmake .. -DLTO=OFF`)")
ADD_DEFINITIONS(-flto)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
ELSE(LTO)
MESSAGE(WARNING "Link time optimization is DISABLED (to enable, run `cmake .. -DLTO=ON`). Performance will be low.")
ENDIF(LTO)
# IF(AVX2)
# MESSAGE(STATUS "AVX2 is enabled (to disable, run `cmake .. -DAVX2=OFF`)")
# ADD_DEFINITIONS(-mavx2)
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mavx2")
# ELSE(LTO)
# MESSAGE(WARNING "AVX2 is DISABLED (to enable, run `cmake .. -DAVX2=ON`). Performance will be low.")
# ENDIF(AVX2)
IF(DPDK)
MESSAGE(STATUS "Intel DPDK support is enabled (to disable, run `cmake .. -DDPDK=OFF`)")
set(RTE_SDK ${CMAKE_SOURCE_DIR}/build/dpdk)
add_definitions(-DUSE_DPDK)
add_definitions(-isystem ${RTE_SDK}/build/include -include rte_config.h)
link_directories(${LINK_DIRECTORIES} ${RTE_SDK}/build/lib)
set(LIBRARIES ${LIBRARIES} -Wl,--whole-archive)
set(LIBRARIES ${LIBRARIES} rte_kvargs rte_mbuf rte_ethdev rte_mempool rte_hash rte_ring rte_eal)
set(LIBRARIES ${LIBRARIES} rte_pmd_i40e rte_pmd_ixgbe rte_pmd_ring)
set(LIBRARIES ${LIBRARIES} -Wl,--no-whole-archive)
set(LIBRARIES ${LIBRARIES} rt dl)
ELSE(DPDK)
MESSAGE(STATUS "Intel DPDK support is disabled (to enable, run `cmake .. -DDPDK=ON`)")
ENDIF(DPDK)
IF(SQLITE)
MESSAGE(STATUS "Sqlite backend support is enabled (to disable, run `cmake .. -DSQLITE=OFF`)")
add_definitions(-DUSE_SQLITE)
set(LIBRARIES ${LIBRARIES} sqlite3)
ELSE(SQLITE)
MESSAGE(STATUS "Sqlite backend support is disabled (to enable, run `cmake .. -DSQLITE=ON`)")
ENDIF(SQLITE)
SET(SOURCES ${SOURCES} src/mica/alloc/hugetlbfs_shm.cc)
SET(SOURCES ${SOURCES} src/mica/directory/directory_client.cc)
SET(SOURCES ${SOURCES} src/mica/directory/etcdcpp/etcd_mod.cc)
SET(SOURCES ${SOURCES} src/mica/util/config.cc)
SET(SOURCES ${SOURCES} src/mica/util/cityhash/city_mod.cc)
SET(SOURCES ${SOURCES} src/mica/util/siphash/siphash24.c)
SET_SOURCE_FILES_PROPERTIES(src/mica/util/siphash/siphash24.c PROPERTIES LANGUAGE CXX)
SET(SOURCES ${SOURCES} src/mica/util/lcore.cc)
SET(SOURCES ${SOURCES} src/mica/util/stopwatch.cc)
SET(SOURCES ${SOURCES} src/mica/util/zipf.cc)
SET(LIBRARIES ${LIBRARIES} rt numa pthread)
SET(LIBRARIES ${LIBRARIES} curl)
# SET(LIBRARIES ${LIBRARIES} boost_coroutine boost_system)
IF(LTO)
ADD_EXECUTABLE(test_table src/mica/test/test_table.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_table ${LIBRARIES})
ADD_EXECUTABLE(test_processor src/mica/test/test_processor.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_processor ${LIBRARIES})
ADD_EXECUTABLE(test_load src/mica/test/test_load.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_load ${LIBRARIES})
ADD_EXECUTABLE(test_zipf src/mica/test/test_zipf.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_zipf ${LIBRARIES})
ADD_EXECUTABLE(test_prefetch src/mica/test/test_prefetch.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_prefetch ${LIBRARIES})
ADD_EXECUTABLE(test_rand src/mica/test/test_rand.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_rand ${LIBRARIES})
ADD_EXECUTABLE(test_hash src/mica/test/test_hash.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_hash ${LIBRARIES})
ADD_EXECUTABLE(test_atomics src/mica/test/test_atomics.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_atomics ${LIBRARIES})
ADD_EXECUTABLE(test_tsc_sync src/mica/test/test_tsc_sync.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_tsc_sync ${LIBRARIES})
ADD_EXECUTABLE(microbench src/mica/test/microbench.cc ${SOURCES})
TARGET_LINK_LIBRARIES(microbench ${LIBRARIES})
ADD_EXECUTABLE(cdf src/mica/test/cdf.cc ${SOURCES})
TARGET_LINK_LIBRARIES(cdf ${LIBRARIES})
IF(DPDK)
ADD_EXECUTABLE(server src/mica/test/server.cc ${SOURCES})
TARGET_LINK_LIBRARIES(server ${LIBRARIES})
ADD_EXECUTABLE(netbench src/mica/test/netbench.cc ${SOURCES})
TARGET_LINK_LIBRARIES(netbench ${LIBRARIES})
ADD_EXECUTABLE(netbench_interval src/mica/test/netbench_interval.cc ${SOURCES})
TARGET_LINK_LIBRARIES(netbench_interval ${LIBRARIES})
IF(SQLITE)
ADD_EXECUTABLE(server_sqlite src/mica/test/server_sqlite.cc ${SOURCES})
TARGET_LINK_LIBRARIES(server_sqlite ${LIBRARIES})
ENDIF(SQLITE)
ENDIF(DPDK)
ELSE(LTO)
ADD_LIBRARY(common ${SOURCES})
ADD_EXECUTABLE(test_table src/mica/test/test_table.cc)
TARGET_LINK_LIBRARIES(test_table common ${LIBRARIES})
ADD_EXECUTABLE(test_processor src/mica/test/test_processor.cc)
TARGET_LINK_LIBRARIES(test_processor common ${LIBRARIES})
ADD_EXECUTABLE(test_load src/mica/test/test_load.cc)
TARGET_LINK_LIBRARIES(test_load common ${LIBRARIES})
ADD_EXECUTABLE(test_zipf src/mica/test/test_zipf.cc)
TARGET_LINK_LIBRARIES(test_zipf common ${LIBRARIES})
ADD_EXECUTABLE(test_prefetch src/mica/test/test_prefetch.cc)
TARGET_LINK_LIBRARIES(test_prefetch common ${LIBRARIES})
ADD_EXECUTABLE(test_rand src/mica/test/test_rand.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_rand ${LIBRARIES})
ADD_EXECUTABLE(test_hash src/mica/test/test_hash.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_hash ${LIBRARIES})
ADD_EXECUTABLE(test_atomics src/mica/test/test_atomics.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_atomics ${LIBRARIES})
ADD_EXECUTABLE(test_tsc_sync src/mica/test/test_tsc_sync.cc ${SOURCES})
TARGET_LINK_LIBRARIES(test_tsc_sync ${LIBRARIES})
ADD_EXECUTABLE(microbench src/mica/test/microbench.cc)
TARGET_LINK_LIBRARIES(microbench common ${LIBRARIES})
ADD_EXECUTABLE(cdf src/mica/test/cdf.cc)
TARGET_LINK_LIBRARIES(cdf common ${LIBRARIES})
IF(DPDK)
ADD_EXECUTABLE(server src/mica/test/server.cc)
TARGET_LINK_LIBRARIES(server common ${LIBRARIES})
ADD_EXECUTABLE(netbench src/mica/test/netbench.cc)
TARGET_LINK_LIBRARIES(netbench common ${LIBRARIES})
ADD_EXECUTABLE(netbench_interval src/mica/test/netbench_interval.cc)
TARGET_LINK_LIBRARIES(netbench_interval common ${LIBRARIES})
IF(SQLITE)
ADD_EXECUTABLE(server_sqlite src/mica/test/server_sqlite.cc)
TARGET_LINK_LIBRARIES(server_sqlite common ${LIBRARIES})
ENDIF(SQLITE)
ENDIF(DPDK)
ENDIF(LTO)