forked from KittensBasket/dasboot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
199 lines (151 loc) · 4.58 KB
/
CMakeLists.txt
File metadata and controls
199 lines (151 loc) · 4.58 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
cmake_minimum_required (VERSION 3.22.1)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
project(dasboot)
# Find compilers
find_program(CMAKE_CXX_COMPILER NAMES clang++ REQUIRED)
find_program(CMAKE_CXX_COMPILER NAMES clang REQUIRED)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "C++ compiler" FORCE)
set(CMAKE_C_COMPILER "clang" CACHE STRING "C compiler" FORCE)
# ========================================== Start install dependencies ==========================================
include(FetchContent)
# <ZeroMQ>
set(ZMQ_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(CPPZMQ_BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
zeromq_c
GIT_REPOSITORY https://github.com/zeromq/libzmq.git
GIT_TAG v4.3.5
)
FetchContent_Declare(
zeromq
GIT_REPOSITORY https://github.com/zeromq/cppzmq.git
GIT_TAG v4.10.0
)
FetchContent_MakeAvailable(zeromq_c zeromq)
include_directories(${zeromq_c_SOURCE_DIR}/include)
include_directories(${zeromq_SOURCE_DIR}/include)
# </ZeroMQ>
# <Cli11>
FetchContent_Declare(
cli11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_TAG v2.5.0
)
FetchContent_MakeAvailable(cli11)
include_directories(${cli11_SOURCE_DIR}/include)
# </Cli11>
# <GTest>
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
# </GTest>
# <Protobuf>
set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(protobuf_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG v21.4
SOURCE_SUBDIR cmake
)
FetchContent_MakeAvailable(protobuf)
include_directories(${protobuf_INCLUDE_DIR})
include_directories(${protobuf_SOURCE_DIR}/src)
# </Protobuf>
# <nlohmann_json>
set(json_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(json_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json
GIT_TAG v3.12.0
)
FetchContent_MakeAvailable(json)
include_directories(${json_SOURCE_DIR}/include)
# </nlohmann_json>
# <libcurl>
set(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
curl
GIT_REPOSITORY https://github.com/curl/curl.git
GIT_TAG curl-8_7_1
)
FetchContent_MakeAvailable(curl)
include_directories(${curl_SOURCE_DIR}/include)
# <libcurl>
# <libarchive>
set(ENABLE_TEST OFF CACHE BOOL "" FORCE)
set(ENABLE_CPIO OFF CACHE BOOL "" FORCE)
set(ENABLE_CAT OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
libarchive
GIT_REPOSITORY https://github.com/libarchive/libarchive.git
GIT_TAG v3.7.2
)
FetchContent_MakeAvailable(libarchive)
include_directories(${libarchive_SOURCE_DIR}/libarchive)
# </libarchive>
# ========================================== End install dependencies ==========================================
# Start flags
function(apply_compile_flags target)
if (CMAKE_CXX_COMPILER)
target_compile_options(${target} PRIVATE
-Werror
-Wall
-Wextra
-Wpedantic
-Wcast-align
-Wcast-qual
-Wconversion
-Wctor-dtor-privacy
-Wenum-compare
-Wfloat-equal
-Wnon-virtual-dtor
-Wold-style-cast
-Woverloaded-virtual
-Wredundant-decls
-Wsign-conversion
-Wsign-promo
-Wzero-as-null-pointer-constant
-Wnonnull
-O3
#-ffast-math - could not be used here, because json headers include uses of INF
# For coverage:
-fprofile-instr-generate
-fcoverage-mapping
)
# For coverage
add_link_options(-fprofile-instr-generate -fcoverage-mapping)
endif()
endfunction()
# End flags
# Start clang-tidy
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
if(NOT CLANG_TIDY_COMMAND)
message(FATAL_ERROR "Clang-tidy is not found!")
else()
message(STATUS "Clang-tidy is ON")
# Google C++ Style
set(CLANGTIDY_EXTRA_ARGS
"-checks=google-*"
"-warnings-as-errors=*"
)
set(CMAKE_CXX_CLANG_TIDY
${CLANG_TIDY_COMMAND};
-p=${CMAKE_BINARY_DIR};
--header-filter='*/dasboot/*';
${CLANGTIDY_EXTRA_ARGS};)
endif()
# End clang-tidy
include_directories(.)
enable_testing()
add_subdirectory(dasboot)