-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
175 lines (142 loc) · 5.97 KB
/
Copy pathCMakeLists.txt
File metadata and controls
175 lines (142 loc) · 5.97 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
cmake_minimum_required(VERSION 3.22)
project(SILO)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif ()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -D SILO_DEBUG_ASSERTIONS=1")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D SILO_DEBUG_ASSERTIONS=0")
# Work-around only for MacOS
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -D SILO_DEBUG_ASSERTIONS=1")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D SILO_DEBUG_ASSERTIONS=0")
endif ()
set(CMAKE_CXX_STANDARD 23)
# For find_package calls in Module mode (looking for the Find<lib>.cmake files)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_BINARY_DIR}/generators/")
# For find_package calls in config mode / find_dependency calls
# (looking for the <lib>-config.cmake files of transitive dependencies of modules, e.g. spdlog->fmt)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${CMAKE_BINARY_DIR}/generators/")
# Export compile commands for configuring language servers or debugging the build
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# ---------------------------------------------------------------------------
# Allocator
# ---------------------------------------------------------------------------
option(USE_MIMALLOC "Use mimalloc allocator" ON)
# Only use mimalloc in Release mode, because of conflicts with ASAN
if(USE_MIMALLOC AND ${CMAKE_BUILD_TYPE} STREQUAL "Release")
message("Using mimalloc as allocator")
find_package(mimalloc REQUIRED)
add_compile_definitions(SILO_USE_MIMALLOC=1)
set(MIMALLOC_LIB mimalloc-static)
else()
set(MIMALLOC_LIB "")
endif()
# ---------------------------------------------------------------------------
# Compile definitions
# ---------------------------------------------------------------------------
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
add_compile_definitions(SIMDJSON_EXCEPTIONS=0)
# ---------------------------------------------------------------------------
# Dependencies
# ---------------------------------------------------------------------------
find_package(Arrow REQUIRED COMPONENTS Acero XYZ)
find_package(Boost REQUIRED COMPONENTS system serialization iostreams)
find_package(LibLZMA REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(Poco REQUIRED COMPONENTS Net Util JSON)
find_package(re2 REQUIRED)
find_package(roaring REQUIRED)
find_package(spdlog REQUIRED)
find_package(simdjson REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(zstd REQUIRED)
# ---------------------------------------------------------------------------
# Version
# ---------------------------------------------------------------------------
execute_process(
COMMAND cat release_version.txt
OUTPUT_VARIABLE VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE VERSION_AVAILABLE
)
if (VERSION_AVAILABLE EQUAL 0)
message(STATUS "Detected version from release_version.txt: ${VERSION}")
add_compile_definitions(SILO_RELEASE_VERSION="${VERSION}")
else ()
message(STATUS "No release_version.txt available for setting the version")
endif()
# ---------------------------------------------------------------------------
# Includes
# ---------------------------------------------------------------------------
include_directories(
${CMAKE_SOURCE_DIR}/src
)
# ---------------------------------------------------------------------------
# Sources
# ---------------------------------------------------------------------------
file(GLOB_RECURSE SRC_TEST "src/*.test.cpp")
file(GLOB_RECURSE SRC_SILO "src/*.cpp")
list(REMOVE_ITEM SRC_SILO ${SRC_TEST})
set(SRC_SILO_WITHOUT_MAIN ${SRC_SILO})
list(REMOVE_ITEM SRC_SILO_WITHOUT_MAIN "${CMAKE_SOURCE_DIR}/src/main.cpp")
# ---------------------------------------------------------------------------
# Linter
# ---------------------------------------------------------------------------
option(BUILD_WITH_CLANG_TIDY "Build process clang-tidy")
if (NOT CMAKE_BUILD_TYPE STREQUAL Release AND BUILD_WITH_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy-20)
if (NOT CLANG_TIDY_EXE)
message(SEND_ERROR "clang-tidy not found, aborting. You can run the build with '-D BUILD_WITH_CLANG_TIDY=OFF' to disable clang-tidy.")
else ()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
message(STATUS "run clang tidy with: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};--warnings-as-errors=*")
endif ()
endif ()
# ---------------------------------------------------------------------------
# Targets
# ---------------------------------------------------------------------------
add_library(silolib OBJECT ${SRC_SILO_WITHOUT_MAIN})
target_link_libraries(
silolib
PUBLIC
${MIMALLOC_LIB} # this should be first
Arrow::arrow_static
ArrowAcero::arrow_acero_static
${Boost_LIBRARIES}
${duckdb_LIBRARIES}
nlohmann_json::nlohmann_json
${roaring_LIBRARIES}
${spdlog_LIBRARIES}
${simdjson_LIBRARIES}
${yaml-cpp_LIBRARIES}
zstd::libzstd_static
Poco::Net
Poco::Util
Poco::JSON
re2::re2
)
add_executable(silo "${CMAKE_SOURCE_DIR}/src/main.cpp" $<TARGET_OBJECTS:silolib>)
target_link_libraries(
silo
PUBLIC
silolib
)
# ---------------------------------------------------------------------------
# Tests
# ---------------------------------------------------------------------------
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTest_INCLUDE_DIRS})
add_executable(silo_test ${SRC_TEST} $<TARGET_OBJECTS:silolib>)
if (NOT GTest_LIBRARIES)
set(GTest_LIBRARIES gtest gmock)
endif ()
target_link_libraries(silo_test PUBLIC ${GTest_LIBRARIES} silolib)
# ---------------------------------------------------------------------------
# Benchmarks
# ---------------------------------------------------------------------------
add_subdirectory(performance)