-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (103 loc) · 4.65 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
cmake_minimum_required(VERSION 3.0)
project(kvstore)
## recordio
# Keep this target here, or else it overwrites compiler settings below
add_subdirectory("3rdparty/recordio")
## Compiler
SET (CMAKE_CXX_COMPILER "/usr/bin/clang++-4.0")
## Standard soft build flags
SET (CMAKE_CXX_FLAGS "-O3 -std=c++14")
## Unit tests
file(GLOB_RECURSE TEST_SOURCES test/*.cpp)
add_executable(unittest ${TEST_SOURCES})
target_include_directories(unittest PRIVATE "src")
target_include_directories(unittest PRIVATE "3rdparty")
target_include_directories(unittest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(unittest pthread proto recordio z ${PROTOBUF_LIBRARY})
## Let Clang go harder on kvstore itself
SET (STRICT_BUILD_FLAGS "-Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op-parentheses -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wswitch-default -Wno-unused")
## Boost
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package( Boost COMPONENTS system thread REQUIRED )
## Simple server
file(GLOB_RECURSE SIMPLE_SOURCES src/simple_server.cpp src/server/*.[c|h]pp)
add_executable(simple_server ${SIMPLE_SOURCES})
set_target_properties(simple_server PROPERTIES COMPILE_FLAGS ${STRICT_BUILD_FLAGS})
target_include_directories(simple_server PRIVATE "3rdparty")
target_link_libraries(simple_server ${Boost_LIBRARIES})
## LRU server
file(GLOB_RECURSE LRU_SOURCES src/lru_server.cpp src/server/*.[c|h]pp)
add_executable(lru_server ${LRU_SOURCES})
set_target_properties(lru_server PROPERTIES COMPILE_FLAGS ${STRICT_BUILD_FLAGS})
target_include_directories(lru_server PRIVATE "3rdparty")
target_link_libraries(lru_server ${Boost_LIBRARIES})
## FIFO/JSON server
file(GLOB_RECURSE FJ_SOURCES src/fifo_json_server.cpp src/server/*.[c|h]pp)
add_executable(fifo_json_server ${FJ_SOURCES})
set_target_properties(fifo_json_server PROPERTIES COMPILE_FLAGS ${STRICT_BUILD_FLAGS})
target_include_directories(fifo_json_server PRIVATE "3rdparty")
target_link_libraries(fifo_json_server ${Boost_LIBRARIES})
## protobuf
add_subdirectory(proto)
## FIFO/protobuf server
file(GLOB_RECURSE FP_SOURCES src/fifo_protobuf_server.cpp src/server/*.[c|h]pp)
add_executable(fifo_protobuf_server ${FP_SOURCES})
set_target_properties(fifo_protobuf_server PROPERTIES COMPILE_FLAGS ${STRICT_BUILD_FLAGS})
target_include_directories(fifo_protobuf_server PRIVATE "3rdparty")
target_include_directories(fifo_protobuf_server PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(fifo_protobuf_server ${Boost_LIBRARIES})
target_link_libraries(fifo_protobuf_server proto recordio z ${PROTOBUF_LIBRARY})
## LRU/JSON/protobuf server
file(GLOB_RECURSE LJP_SOURCES src/lru_json_protobuf_server.cpp src/server/*.[c|h]pp)
add_executable(lru_json_protobuf_server ${LJP_SOURCES})
set_target_properties(lru_json_protobuf_server PROPERTIES COMPILE_FLAGS ${STRICT_BUILD_FLAGS})
target_include_directories(lru_json_protobuf_server PRIVATE "3rdparty")
target_include_directories(lru_json_protobuf_server PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(lru_json_protobuf_server ${Boost_LIBRARIES})
target_link_libraries(lru_json_protobuf_server proto recordio z ${PROTOBUF_LIBRARY})
## Client
file(GLOB_RECURSE CLIENT_SOURCES src/client.cpp)
add_executable(client ${CLIENT_SOURCES})
set_target_properties(client PROPERTIES COMPILE_FLAGS ${STRICT_BUILD_FLAGS})
target_include_directories(client PRIVATE "3rdparty")
target_link_libraries(client pthread)
## Collect for convenience
file(GLOB_RECURSE KVSTORE_SOURCES ${SIMPLE_SOURCES} ${FJ_SOURCES} ${LRU_SOURCES} ${FP_SOURCES} ${LJP_SOURCES} ${CLIENT_SOURCES})
## cppcheck
add_custom_target(
cppcheck
COMMAND cppcheck
--enable=all
--std=c++14
--language=c++
# --check-config # Uncomment to see if cppcheck is missing something
${KVSTORE_SOURCES}
${TEST_SOURCES}
-I ${PROJECT_SOURCE_DIR}/src/
)
## clang-tidy
add_custom_target(
clang-tidy
COMMAND clang-tidy-4.0
# -fix # Warning: Uncommenting lets clang-tidy perform changes in source
${KVSTORE_SOURCES}
-checks=*,-llvm-header-guard,-header-filter=.* --
-std=c++14 # Removing this may crash clang-tidy
-I${PROJECT_SOURCE_DIR}/3rdparty/
-I${CMAKE_CURRENT_BINARY_DIR}
)
## clang-format
add_custom_target(
clang-format
COMMAND clang-format-4.0
-i
-style='{ BasedOnStyle: google,
Standard: Cpp11,
ColumnLimit: 88,
AlignConsecutiveAssignments: true,
SortIncludes: false }' # Conflicts with clang-tidy [llvm-include-order]
${KVSTORE_SOURCES}
${TEST_SOURCES}
)