This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
106 lines (94 loc) · 2.87 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
cmake_minimum_required(VERSION 3.16)
project(smallkv)
set(CMAKE_CXX_STANDARD 17)
add_compile_options(-march=native -ffast-math)
set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_CXX_FLAGS "-Werror -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
option(SMALLKV-UNITTEST "build unit-test" ON)
# gtest
find_package(GTest REQUIRED)
include_directories(${GTest_INCLUDE_DIRS})
# spdlog
find_package(spdlog REQUIRED)
include_directories(${spdlog_INCLUDE_DIRS})
# nlohmann_json
find_package(nlohmann_json 3.2.0 REQUIRED)
include_directories(src)
file(GLOB_RECURSE SRC
src/cache/*.cpp
src/cache/*.h
src/compress/*.cpp
src/compress/*.h
src/config/*.cpp
src/config/*.h
src/db/*.cpp
src/db/*.h
src/file/*.cpp
src/file/*.h
src/filter/*.cpp
src/filter/*.h
src/log/*.cpp
src/log/*.h
src/memory/*.cpp
src/memory/*.h
src/memtable/*.cpp
src/memtable/*.h
src/recovery/*.cpp
src/recovery/*.h
src/sst_parser/*.cpp
src/sst_parser/*.h
src/table/*.cpp
src/table/*.h
src/utils/*.cpp
src/utils/*.h
src/wal/*.cpp
src/wal/*.h
src/main.cpp)
file(GLOB_RECURSE SRC_WITHOUT_MAIN
src/cache/*.cpp
src/cache/*.h
src/compress/*.cpp
src/compress/*.h
src/config/*.cpp
src/config/*.h
src/db/*.cpp
src/db/*.h
src/file/*.cpp
src/file/*.h
src/filter/*.cpp
src/filter/*.h
src/log/*.cpp
src/log/*.h
src/memory/*.cpp
src/memory/*.h
src/memtable/*.cpp
src/memtable/*.h
src/recovery/*.cpp
src/recovery/*.h
src/sst_parser/*.cpp
src/sst_parser/*.h
src/table/*.cpp
src/table/*.h
src/utils/*.cpp
src/utils/*.h
src/wal/*.cpp
src/wal/*.h)
# 生成smallkv
add_executable(smallkv ${SRC})
target_link_libraries(smallkv PRIVATE pthread nlohmann_json::nlohmann_json)
# 链接abseil中的crc32静态库
target_link_libraries(smallkv PRIVATE libabsl_crc32c.a libabsl_crc_internal.a libabsl_raw_logging_internal.a)
# 生成客户端,底层是smallkv
file(GLOB_RECURSE SRC_CLI cli/* ${SRC_WITHOUT_MAIN})
add_executable(smallkv-cli ${SRC_CLI})
target_link_libraries(smallkv-cli PRIVATE pthread nlohmann_json::nlohmann_json)
target_link_libraries(smallkv-cli PRIVATE libabsl_crc32c.a libabsl_crc_internal.a libabsl_raw_logging_internal.a)
if (SMALLKV-UNITTEST)
enable_testing()
file(GLOB_RECURSE SRC_TEST
tests/*.cpp)
add_executable(smallkv-unitest ${SRC_WITHOUT_MAIN} ${SRC_TEST})
target_link_libraries(smallkv-unitest PRIVATE gtest pthread nlohmann_json::nlohmann_json)
target_link_libraries(smallkv-unitest PRIVATE libabsl_crc32c.a libabsl_crc_internal.a libabsl_raw_logging_internal.a)
endif (SMALLKV-UNITTEST)