-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
230 lines (188 loc) · 7.1 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
## Set root directory of Wukong
set(ROOT $ENV{WUKONG_ROOT})
set(CMAKE_CXX_COMPILER ${ROOT}/deps/openmpi-1.6.5-install/bin/mpic++)
project (wukong)
## CMake version
cmake_minimum_required(VERSION 2.8)
## Use C++17 features
add_definitions(-std=c++17)
## Set dependencies
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fopenmp -Wno-literal-suffix")
set(BOOST_LIB_DIR "${ROOT}/deps/boost_1_67_0-install/lib")
set(WUKONG_LIBS ${WUKONG_LIBS} zmq rt tbb hwloc)
set(BOOST_LIBS ${BOOST_LIBS} ${BOOST_LIB_DIR}/libboost_mpi.so ${BOOST_LIB_DIR}/libboost_serialization.so ${BOOST_LIB_DIR}/libboost_program_options.so ${BOOST_LIB_DIR}/libboost_thread.so ${BOOST_LIB_DIR}/libboost_system.so)
## Set include paths
include_directories(deps/boost_1_67_0-install/include)
include_directories(src)
include_directories(deps)
include_directories(deps/eigen)
include_directories(deps/nlohmann/include)
include_directories(deps/progress-cpp/include)
include_directories(deps/googletest/googletest/include)
include_directories(deps/rpclib)
## Add sub-directories
add_subdirectory(${ROOT}/deps/googletest)
add_subdirectory(${ROOT}/deps/pybind11)
## Source code
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/src/*.hpp")
file(GLOB_RECURSE PYTHON_API_SOURCES "${PROJECT_SOURCE_DIR}/src/api/python/*.cpp")
file(GLOB_RECURSE JAVA_API_SOURCES "${PROJECT_SOURCE_DIR}/src/api/java/*.cpp")
## Set options (cached)
## usage: cmake .. -DUSE_RDMA=OFF -DUSE_HADOOP=ON
#### RDMA
option (USE_RDMA "enable RDMA support" ON)
if(USE_RDMA)
add_definitions(-DHAS_RDMA)
set(WUKONG_LIBS ${WUKONG_LIBS} ibverbs)
endif(USE_RDMA)
#### GPU (NOT YET READY)
option (USE_GPU "enable GPU support" OFF)
if(USE_GPU)
add_definitions(-DUSE_GPU)
find_package(CUDA REQUIRED)
## CUDA configs
set(CUDA_NVCC_FLAGS -arch=sm_35;-std=c++11)
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
set(CUDA_SEPARABLE_COMPILATION ON)
set(WUKONG_LIBS ${WUKONG_LIBS} cudart)
cuda_add_executable(wukong ${SOURCES} "src/wukong.cpp" "src/gpu/gpu_hash.cu")
else(USE_GPU)
add_executable(wukong ${SOURCES} "src/wukong.cpp")
endif(USE_GPU)
#### HDFS
option (USE_HADOOP "enable HDFS support" OFF)
if(USE_HADOOP)
add_definitions(-DHAS_HADOOP)
target_link_libraries(wukong hdfs)
set(WUKONG_LIBS ${WUKONG_LIBS} hdfs)
endif(USE_HADOOP)
#### JEMALLOC
## Currently, all malloc APIs(e.g. malloc/free, new/delete) are jemalloc versions by default.
## To change it, go to deps/deps.sh, modify configuration.
target_link_libraries(wukong jemalloc)
set(WUKONG_LIBS ${WUKONG_LIBS} jemalloc)
option (USE_JEMALLOC "enable jemalloc support" ON)
if(USE_JEMALLOC)
add_definitions(-DUSE_JEMALLOC)
endif(USE_JEMALLOC)
#### Dynamic GStore
option (USE_DYNAMIC_GSTORE "enable dynamic gstore" OFF)
if(USE_DYNAMIC_GSTORE)
add_definitions(-DDYNAMIC_GSTORE)
endif(USE_DYNAMIC_GSTORE)
#### Verstile queries (e.g., ?S ?P ?O)
option (USE_VERSATILE "support versatile queries" ON)
if(USE_VERSATILE)
add_definitions(-DVERSATILE)
endif(USE_VERSATILE)
#### Support t-sparql
option (TRDF_MODE "support t-sparql queries" OFF)
if(TRDF_MODE)
add_definitions(-DTRDF_MODE)
endif(TRDF_MODE)
#### Support yacc & bison for sparql
execute_process(
COMMAND bison -t -rall ${PROJECT_SOURCE_DIR}/src/core/sparql/sparql.y -d -b ${PROJECT_SOURCE_DIR}/src/core/sparql/sparql
)
if(TRDF_MODE)
execute_process(
COMMAND flex -o ${PROJECT_SOURCE_DIR}/src/core/sparql/lex.yy.c ${PROJECT_SOURCE_DIR}/src/core/sparql/sparql_time.l
)
else()
execute_process(
COMMAND flex -o ${PROJECT_SOURCE_DIR}/src/core/sparql/lex.yy.c ${PROJECT_SOURCE_DIR}/src/core/sparql/sparql.l
)
endif(TRDF_MODE)
SET_SOURCE_FILES_PROPERTIES(${PROJECT_SOURCE_DIR}/src/core/sparql/lex.yy.c
${PROJECT_SOURCE_DIR}/src/core/sparql/sparql.tab.c
PROPERTIES LANGUAGE CXX)
add_library(sparql_lex
${PROJECT_SOURCE_DIR}/src/core/sparql/lex.yy.c
${PROJECT_SOURCE_DIR}/src/core/sparql/sparql.tab.c)
set(WUKONG_LIBS ${WUKONG_LIBS} sparql_lex)
#### 64-bit ID (32-bit ID by default)
option (USE_DTYPE_64BIT "use 64-bit ID" OFF)
if(USE_DTYPE_64BIT)
add_definitions(-DDTYPE_64BIT)
endif(USE_DTYPE_64BIT)
#### Build java library
option (BUILD_JNI "build java api library" OFF)
if(BUILD_JNI)
find_package(JNI)
if (JNI_FOUND)
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
else ()
message (FATAL_ERROR "JNI is not found on your machine")
endif()
# build libwukong_java.so
add_library(wukong_java SHARED ${JAVA_API_SOURCES})
target_include_directories(
wukong_java
PRIVATE
${JNI_INCLUDE_DIRS}
)
target_link_libraries(wukong_java
${BOOST_LIBS}
)
# build wukong-api.jar
find_package(Java REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.8" "-target" "1.8")
file(GLOB_RECURSE WUKONG_JAVA_FILES "${PROJECT_SOURCE_DIR}/java/src/main/java/com/*.java")
add_jar(wukong-api ${WUKONG_JAVA_FILES} VERSION 1.0.0-alpha)
endif(BUILD_JNI)
## Build Wukong
target_link_libraries(wukong ${WUKONG_LIBS} ${BOOST_LIBS})
## RPC client demo
add_executable(test_client ${SOURCES} "src/client/test_client.cpp")
target_link_libraries(test_client ${WUKONG_LIBS} ${BOOST_LIBS})
## String server
add_executable(string_server ${SOURCES} "src/stringserver/run_string_server.cpp")
target_link_libraries(string_server ${WUKONG_LIBS} ${BOOST_LIBS})
## String server client demo
add_executable(test_string_client ${SOURCES} "src/stringserver/test_string_client.cpp")
target_link_libraries(test_string_client ${WUKONG_LIBS} ${BOOST_LIBS})
file(GLOB TS "${ROOT}/tests/test_sample.cc")
add_executable(coretest ${TS})
target_link_libraries(coretest gtest gtest_main ${WUKONG_LIBS} ${BOOST_LIBS})
## tests
enable_testing()
add_test(NAME test COMMAND coretest)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose DEPENDS coretest)
## code format
file(GLOB_RECURSE FILES_NEED_FORMAT "src/*.cpp" "src/*.cc" "src/*.hpp" "src/*.h"
"test/*.cc"
)
file(GLOB_RECURSE FILES_NEED_LINT "src/*.cpp" "src/*.cc" "src/*.hpp" "src/*.h"
"test/*.cc"
)
add_custom_target(clformat
COMMAND clang-format --style=file -i ${FILES_NEED_FORMAT}
COMMENT "Running clang-format."
VERBATIM)
add_custom_target(wukong_cpplint
COMMAND ${PROJECT_SOURCE_DIR}/scripts/cpplint.py ${FILES_NEED_LINT}
COMMENT "Running cpplint check."
VERBATIM)
## build docs
find_program(doxygen_EXECUTABLE doxygen NO_CMAKE_SYSTEM_PATH)
find_program(sphinx_build_EXECUTABLE sphinx-build NO_CMAKE_SYSTEM_PATH)
if(doxygen_EXECUTABLE AND sphinx_build_EXECUTABLE)
add_custom_target(wukong_docs
COMMAND ${CMAKE_COMMAND} -E make_directory _build
COMMAND ${doxygen_EXECUTABLE}
COMMAND ${sphinx_build_EXECUTABLE} . _build/html
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/docs
VERBATIM
)
else()
if(NOT doxygen_EXECUTABLE)
message(STATUS "Cannot find the doxygen executable.")
endif()
if(NOT sphinx_build_EXECUTABLE)
message(STATUS "Cannot find the sphinx-build executable.")
endif()
endif()
pybind11_add_module(WukongGraph ${PYTHON_API_SOURCES})
target_link_libraries(WukongGraph zmq rt tbb hwloc ${BOOST_LIBS})