forked from LineairDB/LineairDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
114 lines (100 loc) · 3.61 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
#
# Copyright (C) 2020 Nippon Telegraph and Telephone Corporation.
#
# Licensed 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 3.10)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
project(lineairdb
VERSION 0.1.0
DESCRIPTION "Transactional key-value storage with linearizability and linear-scale performance."
LANGUAGES CXX)
### Options
option(BUILD_TESTS "Build testing executables" ON)
option(BUILD_BENCHMARKS "Build benchmarking executables" ON)
option(BUILD_SANITIZER "Build with clang's address sanitizer" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
### Compiler Options
set(CMAKE_C_FLAGS "--std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -mcx16 -fPIC -march=native -Wno-unused-command-line-argument")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -O0 --save-temps -fno-omit-frame-pointer")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fcolor-diagnostics")
if (BUILD_SANITIZER)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
endif()
endif()
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_DEBUG} -Ofast")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -march=native -Ofast -ffast-math")
### Build as library
file(GLOB_RECURSE SOURCES "src/*.cpp")
add_library(${PROJECT_NAME} ${SOURCES})
if(APPLE)
target_link_libraries(${PROJECT_NAME} PUBLIC pthread jemalloc)
else()
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs atomic pthread jemalloc)
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
### Third-party libraries
add_subdirectory(third_party/msgpack)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/rapidjson/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/libcuckoo>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/concurrentqueue>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/msgpack/include>
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-config
DESTINATION lib
)
install(
EXPORT ${PROJECT_NAME}-config
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME}
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}
DESTINATION include
)
### Tests
if (BUILD_TESTS)
enable_testing()
add_subdirectory(third_party/googletest)
add_subdirectory(tests)
endif()
### Benchmarks
if (BUILD_BENCHMARKS)
enable_testing()
add_subdirectory(bench)
endif()
### Documents
find_package(Doxygen)
if (DOXYGEN_FOUND)
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.debug)
else()
set(doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
endif()
add_custom_target("doc" ${DOXYGEN_EXECUTABLE} ${doxyfile}
DEPENDS ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()