-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
135 lines (117 loc) · 2.74 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
cmake_minimum_required(VERSION 3.15)
project(Redis VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(
${CMAKE_SOURCE_DIR}/binary_tree
${CMAKE_SOURCE_DIR}/container
${CMAKE_SOURCE_DIR}/tree_plus
${CMAKE_SOURCE_DIR}/interface
${CMAKE_SOURCE_DIR}/storage
${CMAKE_SOURCE_DIR}/table
)
set(HEADERS
${CMAKE_SOURCE_DIR}/interface/interface.h
)
set(SOURCES
${CMAKE_SOURCE_DIR}/interface/interface.cc
)
set(PROJECT_SOURCES
${HEADERS}
${SOURCES}
${CMAKE_SOURCE_DIR}/main.cc
)
add_executable(
${PROJECT_NAME}
${PROJECT_SOURCES}
)
add_subdirectory(
${CMAKE_SOURCE_DIR}/binary_tree
)
add_subdirectory(
${CMAKE_SOURCE_DIR}/tree_plus
)
add_subdirectory(
${CMAKE_SOURCE_DIR}/table
)
target_compile_options(
${PROJECT_NAME}
PRIVATE
-Wall
-Werror
-Wextra
-Wpedantic
-fsanitize=address
-Wno-ignored-qualifiers
-Wno-unused-parameter
-Wno-sign-compare
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
BPlusTreeLibrary
HashTableLibrary
SelfBalancingBinarySearchTreeLibrary
-fsanitize=address
)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
# Add cppcheck
find_program(CPPCHECK cppcheck)
file(GLOB_RECURSE ALL_SOURCE_FILES *.cc *.h *.inc)
list(FILTER ALL_SOURCE_FILES EXCLUDE REGEX ".*googletest.*")
if(CPPCHECK)
message(STATUS "cppcheck found: ${CPPCHECK}")
list(
APPEND CPPCHECK_ARGS
"--enable=all"
"--inconclusive"
"--quiet"
"--language=c++"
"--std=c++17"
"--verbose"
"--suppress=unusedFunction"
"--suppress=missingInclude"
"--suppress=unusedStructMember"
"--suppress=variableScope"
"--suppress=functionStatic"
"--suppress=constStatement"
"--suppress=cppcheckError"
"--suppress=constParametr"
"--suppress=passedByValue"
"--suppress=missingReturn"
"--suppress=constParameter"
"--suppress=operatorEqMissingReturnStatement"
"--suppress=postfixOperator"
"--suppress=unmatchedSuppression"
"--suppress=*:${PROJECT_SOURCE_DIR}/lib/*"
)
add_custom_target(
cppcheck
COMMAND ${CPPCHECK} ${CPPCHECK_ARGS} ${ALL_SOURCE_FILES}
)
else()
message(STATUS "cppcheck not found")
endif()
# Add clang-format
find_program(CLANG_FORMAT clang-format)
if(CLANG_FORMAT)
message(STATUS "clang-format found: ${CLANG_FORMAT}")
list(
APPEND CLANG_ARGS
"-i"
"-style=Google"
"--verbose"
)
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT} ${CLANG_ARGS} ${ALL_SOURCE_FILES}
)
else()
message(STATUS "clang-format not found")
endif()