forked from vearch/gamma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
199 lines (165 loc) · 6.16 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
#--------------------------------------------
# GAMMA ENGINE
#--------------------------------------------
project(gamma_engine C CXX)
cmake_minimum_required(VERSION 3.0)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
find_package(FAISS REQUIRED)
option(BUILD_TEST "Build tests" off)
option(BUILD_WITH_GPU "Build gamma with gpu index support" off)
option(BUILD_TOOLS "Build tools" off)
option(TABLE_STR_INT64 "table string int64 address" off)
#ENV VARs
set(THIRDPARTY ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
set(BTREE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/btree)
set(CJSON ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cjson)
set(EASYLOGGINGPP ${CMAKE_CURRENT_SOURCE_DIR}/third_party/easyloggingpp)
set(HASHTABLE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/libcuckoo)
set(UTIL ${CMAKE_CURRENT_SOURCE_DIR}/util)
set(COMMON ${CMAKE_CURRENT_SOURCE_DIR}/common)
set(GAMMA_SEARCH ${CMAKE_CURRENT_SOURCE_DIR}/search)
set(GAMMA_INDEX ${CMAKE_CURRENT_SOURCE_DIR}/index)
set(GAMMA_INDEX_IMPL ${CMAKE_CURRENT_SOURCE_DIR}/index/impl)
set(GAMMA_VECTOR ${CMAKE_CURRENT_SOURCE_DIR}/vector)
set(GAMMA_REALTIME ${CMAKE_CURRENT_SOURCE_DIR}/realtime)
set(GAMMA_TABLE ${CMAKE_CURRENT_SOURCE_DIR}/table)
set(GAMMA_C_API ${CMAKE_CURRENT_SOURCE_DIR}/c_api)
set(GAMMA_IO ${CMAKE_CURRENT_SOURCE_DIR}/io)
set(FLATBUFFERS_OUT ${CMAKE_CURRENT_SOURCE_DIR}/idl/fbs-gen)
if(APPLE)
set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++")
include_directories("/usr/local/include" "/usr/local/opt/llvm/include" "/usr/local/Cellar/[email protected]/1.1.1d/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib" "/usr/local/Cellar/[email protected]/1.1.1d/lib/")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -mavx2 -msse4 -mpopcnt -fopenmp -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -DOPEN_CORE -O0 -w -g3 -gdwarf-2")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -std=c++11 -fPIC -m64 -Wall -O3 -mavx2 -msse4 -mpopcnt -fopenmp -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Werror=narrowing -Wno-deprecated")
if(DEFINED ENV{ROCKSDB_HOME})
message(STATUS "RocksDB home is set=$ENV{ROCKSDB_HOME}")
add_definitions(-DWITH_ROCKSDB)
find_package(RocksDB REQUIRED)
else(DEFINED ENV{ROCKSDB_HOME})
message(STATUS "RocksDB home isn't set, so store_type=RocksDB is not supported! ")
endif(DEFINED ENV{ROCKSDB_HOME})
IF (DEFINED ENV{ZFP_HOME})
MESSAGE(STATUS "ZFP home is set=$ENV{ZFP_HOME}")
ADD_DEFINITIONS(-DWITH_ZFP)
FIND_PACKAGE(ZFP REQUIRED)
ELSE (DEFINED ENV{ZFP_HOME})
MESSAGE(STATUS "ZFP home isn't set, so COMPRESS is not supported! ")
ENDIF (DEFINED ENV{ZFP_HOME})
if(TABLE_STR_INT64)
MESSAGE(STATUS "TABLE_STR_INT64 is on")
ADD_DEFINITIONS(-DTABLE_STR_INT64)
endif(TABLE_STR_INT64)
#INCLUDE DIR
include_directories(
${THIRDPARTY}
${BTREE}
${CJSON}
${EASYLOGGINGPP}
${HASHTABLE}
${UTIL}
${COMMON}
${GAMMA_TABLE}
${GAMMA_SEARCH}
${GAMMA_INDEX}
${GAMMA_INDEX_IMPL}
${GAMMA_VECTOR}
${GAMMA_REALTIME}
${GAMMA_C_API}
${GAMMA_IO}
${FAISS_INCLUDE_DIR}
${RocksDB_INCLUDE_DIR}
${FLATBUFFERS_OUT}/c
${ZFP_INCLUDE_DIR}
)
#LINK LIBRARY
set(LIBRARIES
${FAISS_LIB}
${RocksDB_LIB}
${ZFP_LIB}
-lcrypto
-lzstd
)
#ADDITIONAL SOURCE DIR
aux_source_directory(${THIRDPARTY} DIR_SRCS)
aux_source_directory(${BTREE} DIR_SRCS)
aux_source_directory(${CJSON} DIR_SRCS)
aux_source_directory(${EASYLOGGINGPP} DIR_SRCS)
aux_source_directory(${UTIL} DIR_SRCS)
aux_source_directory(${COMMON} DIR_SRCS)
aux_source_directory(${GAMMA_SEARCH} DIR_SRCS)
aux_source_directory(${GAMMA_INDEX} DIR_SRCS)
aux_source_directory(${GAMMA_INDEX_IMPL} DIR_SRCS)
aux_source_directory(${GAMMA_VECTOR} DIR_SRCS)
aux_source_directory(${GAMMA_REALTIME} DIR_SRCS)
aux_source_directory(${GAMMA_TABLE} DIR_SRCS)
aux_source_directory(${GAMMA_C_API} DIR_SRCS)
aux_source_directory(${GAMMA_C_API}/api_data DIR_SRCS)
aux_source_directory(${GAMMA_IO} DIR_SRCS)
set(LIB_SRCS ${DIR_SRCS})
add_definitions(-DHAVE_NETINET_IN_H)
add_definitions(-DFINTEGER=int)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Debug Mode")
message(STATUS "Flags:" ${CMAKE_CXX_FLAGS_DEBUG})
add_definitions(-DDEBUG_)
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "build type" FORCE)
message(STATUS "Release Mode")
message(STATUS "Flags:" ${CMAKE_CXX_FLAGS_RELEASE})
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
exec_program(
"git"
${CMAKE_CURRENT_SOURCE_DIR}
ARGS "log --format='[sha1]:%h [author]:%cn [time]:%ci [branch]:%d' -1"
OUTPUT_VARIABLE VERSION_SHA1)
add_definitions(-DGIT_SHA1="${VERSION_SHA1}")
exec_program(
"sh"
${CMAKE_CURRENT_SOURCE_DIR}/idl
ARGS "build.sh")
if(PERFORMANCE_TESTING STREQUAL "ON")
message(STATUS "With preformance testing")
add_definitions(-DPERFORMANCE_TESTING)
endif(PERFORMANCE_TESTING STREQUAL "ON")
if(BUILD_WITH_GPU)
message(STATUS "With GPU")
add_definitions(-DBUILD_GPU)
set(GAMMA_GPU ${CMAKE_CURRENT_SOURCE_DIR}/index/impl/gpu)
aux_source_directory(${GAMMA_GPU} DIR_SRCS)
include(cmake/Modules/gpu/CUDA.cmake)
file(GLOB_RECURSE FAISS_GPU_HEADERS ${GAMMA_GPU}/*.h)
file(GLOB_RECURSE FAISS_GPU_CPP ${GAMMA_GPU}/*.cpp)
file(GLOB_RECURSE FAISS_GPU_CC ${GAMMA_GPU}/*.cc)
file(GLOB_RECURSE FAISS_GPU_CUH ${GAMMA_GPU}/*.cuh)
file(GLOB_RECURSE FAISS_GPU_CU ${GAMMA_GPU}/*.cu)
include_directories(
${GAMMA_GPU}
${FAISS_INCLUDE_DIR}
${CUDA_INCLUDE_DIRS}
)
CUDA_ADD_LIBRARY(gamma SHARED
${FAISS_GPU_HEADERS}
${FAISS_GPU_CPP}
${FAISS_GPU_CC}
${FAISS_GPU_CUH}
${FAISS_GPU_CU}
${LIB_SRCS})
else(BUILD_WITH_GPU)
add_library(gamma SHARED ${LIB_SRCS})
endif(BUILD_WITH_GPU)
set(LIB_SRCS ${DIR_SRCS})
target_link_libraries(gamma ${LIBRARIES})
set_target_properties(gamma PROPERTIES VERSION 0.1 SOVERSION 0.1)
install(TARGETS gamma
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES ${GAMMA_C_API}/gamma_api.h DESTINATION include)
if(BUILD_TEST)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
endif(BUILD_TEST)
if(BUILD_TOOLS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools)
endif(BUILD_TOOLS)