Skip to content

Commit 367abd1

Browse files
committed
style: replace cmake-format with gersemi
nicer formatting - support file_sets
1 parent 913682b commit 367abd1

43 files changed

Lines changed: 938 additions & 935 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gersemirc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"indent": 2
3+
}

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ default_install_hook_types:
22
- pre-commit
33
- commit-msg
44
repos:
5-
- repo: https://github.com/cheshirekow/cmake-format-precommit
6-
rev: v0.6.13
5+
# nicer formatting than cmake-format; supports file_sets
6+
- repo: https://github.com/BlankSpruce/gersemi
7+
rev: 0.26.1
78
hooks:
8-
- id: cmake-format
9-
additional_dependencies: [pyyaml]
10-
stages: [pre-commit]
11-
9+
- id: gersemi
10+
1211
- repo: https://github.com/pre-commit/mirrors-clang-format
1312
rev: v20.1.8
1413
hooks:

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ include(cmake/VersionFromGit.cmake)
66

77
version_from_git()
88

9-
project(
10-
aide
11-
LANGUAGES CXX
12-
VERSION ${VERSION}
13-
)
9+
project(aide LANGUAGES CXX VERSION ${VERSION})
1410

1511
set(CMAKE_CXX_EXTENSIONS OFF)
1612

@@ -31,14 +27,12 @@ enable_testing()
3127
add_subdirectory(tests)
3228

3329
if(PROJECT_IS_TOP_LEVEL)
34-
3530
option(aide_ENABLE_DEMO "Builds a small demo application" ON)
3631
add_feature_info(EnableDemo aide_ENABLE_DEMO "Builds the demo application.")
3732

3833
if(aide_ENABLE_DEMO)
3934
add_subdirectory(demo)
4035
endif()
41-
4236
endif()
4337

4438
feature_summary(WHAT ALL)

ProjectOptions.cmake

Lines changed: 79 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@ include(CheckCXXCompilerFlag)
44
include(FeatureSummary)
55

66
macro(aide_supports_sanitizers)
7-
if((CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" OR CMAKE_CXX_COMPILER_ID MATCHES
8-
".*GNU.*") AND NOT WIN32
7+
if(
8+
(
9+
CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*"
10+
OR CMAKE_CXX_COMPILER_ID MATCHES ".*GNU.*"
11+
)
12+
AND NOT WIN32
913
)
1014
set(SUPPORTS_UBSAN ON)
1115
else()
1216
set(SUPPORTS_UBSAN OFF)
1317
endif()
1418

15-
if((CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" OR CMAKE_CXX_COMPILER_ID MATCHES
16-
".*GNU.*") AND WIN32
19+
if(
20+
(
21+
CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*"
22+
OR CMAKE_CXX_COMPILER_ID MATCHES ".*GNU.*"
23+
)
24+
AND WIN32
1725
)
1826
set(SUPPORTS_ASAN OFF)
1927
else()
@@ -32,8 +40,10 @@ macro(aide_setup_options)
3240

3341
cmake_dependent_option(
3442
aide_ENABLE_GLOBAL_HARDENING
35-
"Attempt to push hardening options to built dependencies" ON
36-
aide_ENABLE_HARDENING OFF
43+
"Attempt to push hardening options to built dependencies"
44+
ON
45+
aide_ENABLE_HARDENING
46+
OFF
3747
)
3848

3949
aide_supports_sanitizers()
@@ -57,12 +67,16 @@ macro(aide_setup_options)
5767
option(aide_ENABLE_IPO "Enable IPO/LTO" OFF)
5868
option(aide_WARNINGS_AS_ERRORS "Treat Warnings As Errors" ON)
5969
option(aide_ENABLE_USER_LINKER "Enable user-selected linker" OFF)
60-
option(aide_ENABLE_SANITIZER_ADDRESS "Enable address sanitizer"
61-
${SUPPORTS_ASAN}
70+
option(
71+
aide_ENABLE_SANITIZER_ADDRESS
72+
"Enable address sanitizer"
73+
${SUPPORTS_ASAN}
6274
)
6375
option(aide_ENABLE_SANITIZER_LEAK "Enable leak sanitizer" OFF)
64-
option(aide_ENABLE_SANITIZER_UNDEFINED "Enable undefined sanitizer"
65-
${SUPPORTS_UBSAN}
76+
option(
77+
aide_ENABLE_SANITIZER_UNDEFINED
78+
"Enable undefined sanitizer"
79+
${SUPPORTS_UBSAN}
6680
)
6781
option(aide_ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF)
6882
option(aide_ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" OFF)
@@ -75,57 +89,77 @@ macro(aide_setup_options)
7589
endif()
7690

7791
add_feature_info(
78-
AIDE_ENABLE_COVERAGE aide_ENABLE_COVERAGE "Enable coverage reporting"
92+
AIDE_ENABLE_COVERAGE
93+
aide_ENABLE_COVERAGE
94+
"Enable coverage reporting"
7995
)
8096
add_feature_info(
81-
AIDE_ENABLE_HARDENING aide_ENABLE_HARDENING "Enable hardening"
97+
AIDE_ENABLE_HARDENING
98+
aide_ENABLE_HARDENING
99+
"Enable hardening"
82100
)
83101
add_feature_info(
84-
AIDE_ENABLE_GLOBAL_HARDENING aide_ENABLE_GLOBAL_HARDENING
102+
AIDE_ENABLE_GLOBAL_HARDENING
103+
aide_ENABLE_GLOBAL_HARDENING
85104
"Attempt to push hardening options to built dependencies"
86105
)
87106

88107
add_feature_info(AIDE_ENABLE_IPO aide_ENABLE_IPO "Enable IPO/LTO")
89108
add_feature_info(
90-
AIDE_WARNINGS_AS_ERRORS aide_WARNINGS_AS_ERRORS "Treat Warnings As Errors"
109+
AIDE_WARNINGS_AS_ERRORS
110+
aide_WARNINGS_AS_ERRORS
111+
"Treat Warnings As Errors"
91112
)
92113
add_feature_info(
93-
AIDE_ENABLE_USER_LINKER aide_ENABLE_USER_LINKER
114+
AIDE_ENABLE_USER_LINKER
115+
aide_ENABLE_USER_LINKER
94116
"Enable user-selected linker"
95117
)
96118
add_feature_info(
97-
AIDE_ENABLE_SANITIZER_ADDRESS aide_ENABLE_SANITIZER_ADDRESS
119+
AIDE_ENABLE_SANITIZER_ADDRESS
120+
aide_ENABLE_SANITIZER_ADDRESS
98121
"Enable address sanitizer"
99122
)
100123
add_feature_info(
101-
AIDE_ENABLE_SANITIZER_LEAK aide_ENABLE_SANITIZER_LEAK
124+
AIDE_ENABLE_SANITIZER_LEAK
125+
aide_ENABLE_SANITIZER_LEAK
102126
"Enable leak sanitizer"
103127
)
104128
add_feature_info(
105-
AIDE_ENABLE_SANITIZER_UNDEFINED aide_ENABLE_SANITIZER_UNDEFINED
129+
AIDE_ENABLE_SANITIZER_UNDEFINED
130+
aide_ENABLE_SANITIZER_UNDEFINED
106131
"Enable undefined sanitizer"
107132
)
108133
add_feature_info(
109-
AIDE_ENABLE_SANITIZER_THREAD aide_ENABLE_SANITIZER_THREAD
134+
AIDE_ENABLE_SANITIZER_THREAD
135+
aide_ENABLE_SANITIZER_THREAD
110136
"Enable thread sanitizer"
111137
)
112138
add_feature_info(
113-
AIDE_ENABLE_SANITIZER_MEMORY aide_ENABLE_SANITIZER_MEMORY
139+
AIDE_ENABLE_SANITIZER_MEMORY
140+
aide_ENABLE_SANITIZER_MEMORY
114141
"Enable memory sanitizer"
115142
)
116143
add_feature_info(
117-
AIDE_ENABLE_UNITY_BUILD aide_ENABLE_UNITY_BUILD "Enable unity builds"
144+
AIDE_ENABLE_UNITY_BUILD
145+
aide_ENABLE_UNITY_BUILD
146+
"Enable unity builds"
118147
)
119148
add_feature_info(
120-
AIDE_ENABLE_CLANG_TIDY aide_ENABLE_CLANG_TIDY "Enable clang-tidy"
149+
AIDE_ENABLE_CLANG_TIDY
150+
aide_ENABLE_CLANG_TIDY
151+
"Enable clang-tidy"
121152
)
122153
add_feature_info(
123-
AIDE_ENABLE_CPPCHECK aide_ENABLE_CPPCHECK "Enable cpp-check analysis"
154+
AIDE_ENABLE_CPPCHECK
155+
aide_ENABLE_CPPCHECK
156+
"Enable cpp-check analysis"
124157
)
125158
add_feature_info(AIDE_ENABLE_PCH aide_ENABLE_PCH "Enable precompiled headers")
126159
add_feature_info(AIDE_ENABLE_CACHE aide_ENABLE_CACHE "Enable ccache")
127160
add_feature_info(
128-
AIDE_ENABLE_ABI_COMPLIANCE_CHECK aide_ENABLE_ABI_COMPLIANCE_CHECK
161+
AIDE_ENABLE_ABI_COMPLIANCE_CHECK
162+
aide_ENABLE_ABI_COMPLIANCE_CHECK
129163
"Enable ABI compliance check"
130164
)
131165

@@ -148,7 +182,6 @@ macro(aide_setup_options)
148182
aide_ENABLE_ABI_COMPLIANCE_CHECK
149183
)
150184
endif()
151-
152185
endmacro()
153186

154187
macro(aide_global_options)
@@ -161,11 +194,12 @@ macro(aide_global_options)
161194

162195
if(aide_ENABLE_HARDENING AND aide_ENABLE_GLOBAL_HARDENING)
163196
include(cmake/Hardening.cmake)
164-
if(NOT SUPPORTS_UBSAN
165-
OR aide_ENABLE_SANITIZER_UNDEFINED
166-
OR aide_ENABLE_SANITIZER_ADDRESS
167-
OR aide_ENABLE_SANITIZER_THREAD
168-
OR aide_ENABLE_SANITIZER_LEAK
197+
if(
198+
NOT SUPPORTS_UBSAN
199+
OR aide_ENABLE_SANITIZER_UNDEFINED
200+
OR aide_ENABLE_SANITIZER_ADDRESS
201+
OR aide_ENABLE_SANITIZER_THREAD
202+
OR aide_ENABLE_SANITIZER_LEAK
169203
)
170204
set(ENABLE_UBSAN_MINIMAL_RUNTIME FALSE)
171205
else()
@@ -189,7 +223,7 @@ macro(aide_local_options)
189223

190224
include(cmake/CompilerWarnings.cmake)
191225
aide_set_project_warnings(
192-
aide_warnings ${aide_WARNINGS_AS_ERRORS} "" "" "" ""
226+
aide_warnings ${aide_WARNINGS_AS_ERRORS} "" "" "" ""
193227
)
194228

195229
if(aide_ENABLE_USER_LINKER)
@@ -199,18 +233,20 @@ macro(aide_local_options)
199233

200234
include(cmake/Sanitizers.cmake)
201235
aide_enable_sanitizers(
202-
aide_options ${aide_ENABLE_SANITIZER_ADDRESS} ${aide_ENABLE_SANITIZER_LEAK}
203-
${aide_ENABLE_SANITIZER_UNDEFINED} ${aide_ENABLE_SANITIZER_THREAD}
204-
${aide_ENABLE_SANITIZER_MEMORY}
236+
aide_options ${aide_ENABLE_SANITIZER_ADDRESS} ${aide_ENABLE_SANITIZER_LEAK}
237+
${aide_ENABLE_SANITIZER_UNDEFINED} ${aide_ENABLE_SANITIZER_THREAD}
238+
${aide_ENABLE_SANITIZER_MEMORY}
205239
)
206240

207241
set_target_properties(
208-
aide_options PROPERTIES UNITY_BUILD ${aide_ENABLE_UNITY_BUILD}
242+
aide_options
243+
PROPERTIES UNITY_BUILD ${aide_ENABLE_UNITY_BUILD}
209244
)
210245

211246
if(aide_ENABLE_PCH)
212247
target_precompile_headers(
213-
aide_options INTERFACE <vector> <string> <utility>
248+
aide_options
249+
INTERFACE <vector> <string> <utility>
214250
)
215251
endif()
216252

@@ -226,7 +262,7 @@ macro(aide_local_options)
226262

227263
if(aide_ENABLE_CPPCHECK)
228264
aide_enable_cppcheck(
229-
${aide_WARNINGS_AS_ERRORS} "" # override cppcheck options
265+
${aide_WARNINGS_AS_ERRORS} "" # override cppcheck options
230266
)
231267
endif()
232268

@@ -250,17 +286,17 @@ macro(aide_local_options)
250286

251287
if(aide_ENABLE_HARDENING AND NOT aide_ENABLE_GLOBAL_HARDENING)
252288
include(cmake/Hardening.cmake)
253-
if(NOT SUPPORTS_UBSAN
254-
OR aide_ENABLE_SANITIZER_UNDEFINED
255-
OR aide_ENABLE_SANITIZER_ADDRESS
256-
OR aide_ENABLE_SANITIZER_THREAD
257-
OR aide_ENABLE_SANITIZER_LEAK
289+
if(
290+
NOT SUPPORTS_UBSAN
291+
OR aide_ENABLE_SANITIZER_UNDEFINED
292+
OR aide_ENABLE_SANITIZER_ADDRESS
293+
OR aide_ENABLE_SANITIZER_THREAD
294+
OR aide_ENABLE_SANITIZER_LEAK
258295
)
259296
set(ENABLE_UBSAN_MINIMAL_RUNTIME FALSE)
260297
else()
261298
set(ENABLE_UBSAN_MINIMAL_RUNTIME TRUE)
262299
endif()
263300
aide_enable_hardening(aide_options OFF ${ENABLE_UBSAN_MINIMAL_RUNTIME})
264301
endif()
265-
266302
endmacro()

aide/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ include(${CMAKE_CURRENT_LIST_DIR}/../cmake/VersionFromGit.cmake)
44

55
version_from_git()
66

7-
project(
8-
aide.library
9-
LANGUAGES CXX
10-
VERSION ${VERSION}
11-
)
7+
project(aide.library LANGUAGES CXX VERSION ${VERSION})
128

139
set(CMAKE_CXX_EXTENSIONS OFF)
1410

1511
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CheckRequiredCXXStandard.cmake)
1612

1713
if(PROJECT_IS_TOP_LEVEL)
18-
1914
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/PreventInSourceBuilds.cmake)
2015
include(${CMAKE_CURRENT_LIST_DIR}/../ProjectOptions.cmake)
2116

aide/dependencies/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ string(SUBSTRING ${markdown_content} 0 ${markdown_substring} markdown_content)
115115
if(AIDE_CHECK_LICENSES_AVAILABILITY)
116116
configure_file(licenses.hml.in licenses.html @ONLY)
117117
configure_file(
118-
licenses.md.in ${CMAKE_CURRENT_LIST_DIR}/../../3rd-party-licenses.md @ONLY
118+
licenses.md.in
119+
${CMAKE_CURRENT_LIST_DIR}/../../3rd-party-licenses.md
120+
@ONLY
119121
)
120122
endif()

aide/dependencies/Qt.cmake

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
22

3-
find_package(
4-
Qt6
5-
COMPONENTS Core Widgets
6-
QUIET
7-
)
3+
find_package(Qt6 COMPONENTS Core Widgets QUIET)
84

95
if(TARGET Qt6::Core)
10-
find_package(
11-
Qt6
12-
COMPONENTS Core Widgets
13-
REQUIRED
14-
)
6+
find_package(Qt6 COMPONENTS Core Widgets REQUIRED)
157

168
find_package(Qt6LinguistTools)
179
else()
1810
if(NOT TARGET Qt5::Core)
19-
find_package(
20-
Qt5
21-
COMPONENTS Core Widgets
22-
REQUIRED
23-
)
11+
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
2412

2513
if(TARGET Qt5::Core)
2614
set_target_properties(
27-
Qt5::Core Qt5::Widgets Qt5::moc Qt5::uic Qt5::rcc
15+
Qt5::Core
16+
Qt5::Widgets
17+
Qt5::moc
18+
Qt5::uic
19+
Qt5::rcc
2820
PROPERTIES IMPORTED_GLOBAL TRUE
2921
)
3022
if(NOT TARGET Qt::Core)

0 commit comments

Comments
 (0)