-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
257 lines (231 loc) · 5.35 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
cmake_minimum_required(VERSION 3.19..3.27)
# integrate with vcpkg
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
project(AdventOfCOde)
include(Inputs.cmake)
if(MSVC)
find_program(CPPCHECK NAMES "cppcheck.exe")
if(CPPCHECK)
find_file(FMT_FORMAT_INL NAMES fmt/format-inl.h)
set(CMAKE_CXX_CPPCHECK ${CPPCHECK} -q --enable=all --suppress=*:${FMT_FORMAT_INL} --suppress=missingIncludeSystem)
endif()
else()
# find_program(CLANG_TIDY NAMES "clang-tidy")
# if(CLANG_TIDY)
# set(CLANG_TIDY_CHECK_LIST
# cppcoreguidelines-*
# -cppcoreguidelines-avoid-magic-numbers
# modernize-*
# -modernize-use-trailing-return-type
# performance-*
# readability-*
# -readability-braces-around-statements # ne fonctionne pas avec le style Alleman
# -readability-magic-numbers
# )
# list(JOIN CLANG_TIDY_CHECK_LIST "," CLANG_TIDY_CHECKS)
# set(CMAKE_CXX_CLANG_TIDY
# ${CLANG_TIDY}
# -checks=${CLANG_TIDY_CHECKS}
# -header-filter=.*
# --format-style=file
# --warnings-as-errors=*
# )
# endif()
endif()
add_library(project_warnings INTERFACE)
if(MSVC)
target_compile_options(project_warnings INTERFACE
/W4
/WX
/diagnostics:caret
/permissive-
)
else()
target_compile_options(project_warnings INTERFACE
-Wall
-Wcast-align
-Wconversion
-Wdouble-promotion
-Werror
-Wextra
-Wformat=2
-Wnon-virtual-dtor
-Wnull-dereference
-Wold-style-cast
-Woverloaded-virtual
-Wpedantic
-Wshadow
-Wsign-conversion
-Wunused
-Wno-psabi
)
endif()
add_library(md5 OBJECT
src/common/md5.c
src/common/md5.h
src/common/md5.hpp
)
add_library(common STATIC
src/common.hpp
src/common/combinations.hpp
src/common/defaultdict.hpp
src/common/dijkstra.hpp
src/common/input.hpp
src/common/intcode.cpp
src/common/intcode.hpp
src/common/numbers.hpp
src/common/point2d.hpp
src/common/point3d.hpp
src/common/point4d.hpp
src/common/range.hpp
src/common/string.cpp
src/common/string.hpp
src/common/terminal.cpp
src/common/terminal.hpp
$<TARGET_OBJECTS:md5>
)
if(WIN32)
target_compile_definitions(common PUBLIC
_USE_MATH_DEFINES
NOMINMAX
WIN32_LEAN_AND_MEAN
)
endif()
target_compile_features(common PUBLIC cxx_std_20)
target_link_libraries(common PUBLIC project_warnings)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(common PUBLIC fmt::fmt-header-only)
find_package(Microsoft.GSL CONFIG REQUIRED)
target_link_libraries(common PRIVATE Microsoft.GSL::GSL)
find_package(RapidJSON CONFIG REQUIRED)
target_link_libraries(common PRIVATE rapidjson)
find_package(ctre CONFIG REQUIRED)
target_link_libraries(common PRIVATE ctre::ctre)
function(add_aoc year day)
set(aoc ${year}-day${day})
add_executable(${aoc} src/${year}/day${day}.cpp src/${year}/day${day}.hpp)
target_link_libraries(${aoc} PRIVATE common)
add_custom_target(run-${year}-${day} ${aoc} DEPENDS ${aoc})
add_aoc_input(${year} ${day})
target_link_libraries(${aoc} PUBLIC resources-${year}-${day})
if(TARGET run-${year})
add_dependencies(run-${year} run-${year}-${day})
else()
add_custom_target(run-${year} DEPENDS run-${year}-${day})
endif()
if(TARGET run)
add_dependencies(run run-${year}-${day})
else()
add_custom_target(run DEPENDS run-${year}-${day})
endif()
set_property(TARGET ${aoc} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${aoc}.pdb)
endfunction()
find_program(CLANG_FORMAT NAMES "clang-format")
if(CLANG_FORMAT)
file(GLOB_RECURSE FILES_TO_FORMAT src/*.cpp src/*.hpp)
add_custom_target(clang-format COMMAND ${CLANG_FORMAT} -i ${FILES_TO_FORMAT})
endif()
add_aoc(2015 1)
add_aoc(2015 2)
add_aoc(2015 3)
add_aoc(2015 4)
add_aoc(2015 5)
add_aoc(2015 6)
add_aoc(2015 7)
add_aoc(2015 8)
add_aoc(2015 9)
add_aoc(2015 10)
add_aoc(2015 11)
add_aoc(2015 12)
add_aoc(2015 13)
add_aoc(2015 14)
add_aoc(2015 15)
add_aoc(2015 16)
add_aoc(2015 17)
add_aoc(2015 18)
add_aoc(2015 19)
add_aoc(2015 20)
add_aoc(2015 21)
add_aoc(2015 22)
add_aoc(2015 23)
add_aoc(2015 24)
add_aoc(2015 25)
add_aoc(2016 1)
add_aoc(2016 2)
add_aoc(2016 3)
add_aoc(2016 4)
add_aoc(2019 1)
add_aoc(2019 2)
add_aoc(2019 3)
add_aoc(2019 4)
add_aoc(2019 5)
add_aoc(2019 6)
add_aoc(2019 7)
add_aoc(2019 8)
add_aoc(2019 9)
add_aoc(2019 10)
add_aoc(2019 11)
add_aoc(2019 12)
add_aoc(2019 13)
add_aoc(2019 14)
add_aoc(2019 15)
add_aoc(2019 16)
add_aoc(2019 17)
add_aoc(2019 19)
add_aoc(2020 1)
add_aoc(2020 2)
add_aoc(2020 3)
add_aoc(2020 4)
add_aoc(2020 5)
add_aoc(2020 6)
add_aoc(2020 7)
add_aoc(2020 8)
add_aoc(2020 9)
add_aoc(2020 10)
add_aoc(2020 11)
add_aoc(2020 12)
add_aoc(2020 13)
add_aoc(2020 14)
add_aoc(2020 15)
add_aoc(2020 16)
add_aoc(2020 17)
add_aoc(2020 18)
add_aoc(2020 19)
add_aoc(2021 1)
add_aoc(2021 2)
add_aoc(2021 3)
add_aoc(2021 4)
add_aoc(2021 5)
add_aoc(2021 6)
add_aoc(2021 7)
add_aoc(2021 8)
add_aoc(2021 9)
add_aoc(2021 10)
add_aoc(2021 11)
add_aoc(2021 12)
add_aoc(2021 13)
add_aoc(2021 14)
add_aoc(2021 15)
add_aoc(2022 1)
add_aoc(2022 2)
add_aoc(2022 3)
add_aoc(2022 4)
add_aoc(2022 5)
add_aoc(2022 6)
add_aoc(2022 7)
add_aoc(2022 8)
add_aoc(2022 9)
add_aoc(2022 10)
add_aoc(2022 11)
add_aoc(2022 12)
add_aoc(2022 13)
add_aoc(2022 14)
add_aoc(2022 15)
add_aoc(2022 16)
add_aoc(2023 1)
add_aoc(2023 2)
add_aoc(2023 3)
add_aoc(2023 4)
add_aoc(2023 5)
add_aoc(2023 6)
add_aoc(2023 7)