-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
156 lines (129 loc) · 4.64 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
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(ustore)
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
include(cmake/Utils.cmake)
# --- [ Option for static or dynamic library generation
# --- [ ON to generate dynamic library
OPTION(DYNAMIC_LIB "Generate dynamic library libustore.so,
otherwise libustore.a" ON)
# --- [ Options
OPTION(USE_LEVELDB "Use LevelDB as chunk storage" OFF)
OPTION(USE_CRYPTOPP "Use Crypto++ library to calculate chunk hash" ON)
OPTION(USE_SHA256 "Choose SHA-256 hash to calculate chunk hash" OFF)
OPTION(USE_BLAKE2b "Choose BLAKE2b hash to calculate chunk hash,
need to turn USE_CRYPTOPP ON first" ON)
OPTION(ENABLE_TEST "Compile test module" ON)
OPTION(TEST_NODEBUILDER "Test node builder" OFF)
OPTION(ENABLE_DEBUG "Enable debug mode" OFF)
OPTION(USE_RDMA "Use RDMA" OFF)
OPTION(USE_SIMPLE_HEAD_VERSION "Use simple head version" ON)
OPTION(USE_ROCKSDB "Use RocksDB" OFF)
OPTION(USE_ROCKS_STORE "Use RocksDB-based chunk store" OFF)
OPTION(ENABLE_EXAMPLE "Compile example module" ON)
OPTION(ENABLE_GO "Generate Golang binding" OFF)
OPTION(ENABLE_STORE_INFO "Enable profiling storage" ON)
if (USE_BLAKE2b AND USE_SHA256)
message(FATAL_ERROR "options USE_BLAKE2b and USE_BLAKE2b are"
" mutually exclusive, choose *ONE* only")
endif()
if (USE_CRYPTOPP)
message(STATUS "Use Crypto++ library")
add_definitions(-DUSE_CRYPTOPP)
endif()
if (USE_BLAKE2b)
if (NOT USE_CRYPTOPP)
message(FATAL_ERROR "Cannot use BLAKE2b to calculate"
" chunk hash without Crypto++")
endif()
message(STATUS "Use BLAKE2b hash")
add_definitions(-DUSE_BLAKE2b)
endif()
if(USE_SHA256)
message(STATUS "Use SHA-256 hash")
add_definitions(-DUSE_SHA256)
endif()
if(TEST_NODEBUILDER)
message(STATUS "Test Node Builder with Specific Rolling Hasher")
add_definitions(-DTEST_NODEBUILDER)
endif()
if(ENABLE_DEBUG)
message(STATUS "Use debug mode")
add_definitions(-DDEBUG)
endif()
if(USE_RDMA)
message(STATUS "Use RDMA")
add_definitions(-DUSE_RDMA)
endif()
if(USE_SIMPLE_HEAD_VERSION)
message(STATUS "Use simple head version")
add_definitions(-DUSE_SIMPLE_HEAD_VERSION)
endif()
if(NOT USE_SIMPLE_HEAD_VERSION AND NOT USE_ROCKSDB)
message(STATUS "No use of simple head version recalls RocksDB")
set(USE_ROCKSDB ON CACHE BOOL "Recall RocksDB" FORCE)
endif()
if(USE_ROCKS_STORE)
message(STATUS "Use RocksDB-based chunk store")
add_definitions(-DUSE_ROCKS_STORE)
endif()
if(USE_ROCKS_STORE AND NOT USE_ROCKSDB)
message(STATUS "Use of RocksDB-based chunk store recalls RocksDB")
set(USE_ROCKSDB ON CACHE BOOL "Recall RocksDB" FORCE)
endif()
if(ENABLE_STORE_INFO)
message(STATUS "Enable profiling storage")
add_definitions(-DENABLE_STORE_INFO)
endif()
SET(BOOST_COMPONENT "filesystem")
LIST(APPEND BOOST_COMPONENT "program_options")
LIST(APPEND BOOST_COMPONENT "thread")
# ---[ Dependencies
include(cmake/Dependencies.cmake)
enable_testing()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pthread -Wall -Wno-unused-function")
if(ENABLE_DEBUG)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
if (DYNAMIC_LIB)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
# SET(PROTOBUF_PROTOC_EXECUTABLE "protoc")
MESSAGE(STATUS "${PROTOBUF_PROTOC_EXECUTABLE}")
LIST(APPEND USTORE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
INCLUDE_DIRECTORIES(${USTORE_INCLUDE_DIR})
MESSAGE(STATUS "include: ${USTORE_INCLUDE_DIR}")
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# copy the conf directory
FILE(COPY conf DESTINATION ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "copied directory: conf")
# copy the bin directory
FILE(COPY bin DESTINATION ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "copied directory: bin")
IF(ENABLE_TEST)
ADD_SUBDIRECTORY(test)
ENDIF()
IF(ENABLE_EXAMPLE)
ADD_SUBDIRECTORY(example)
ENDIF()
IF(ENABLE_GO)
ADD_SUBDIRECTORY(go)
ENDIF()
ADD_SUBDIRECTORY(src)