Skip to content

Commit 7eb78f2

Browse files
author
Vano
committed
pre-commit hook for cmake
1 parent db8684f commit 7eb78f2

File tree

2 files changed

+293
-0
lines changed

2 files changed

+293
-0
lines changed

.cmake-format.json

+285
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
{
2+
"_help_parse": "Options affecting listfile parsing",
3+
"parse": {
4+
"_help_additional_commands": [
5+
"Specify structure for custom cmake functions"
6+
],
7+
"additional_commands": {
8+
"foo": {
9+
"flags": [
10+
"BAR",
11+
"BAZ"
12+
],
13+
"kwargs": {
14+
"DEPENDS": "*",
15+
"HEADERS": "*",
16+
"SOURCES": "*"
17+
}
18+
}
19+
},
20+
"_help_vartags": [
21+
"Specify variable tags."
22+
],
23+
"vartags": [],
24+
"_help_proptags": [
25+
"Specify property tags."
26+
],
27+
"proptags": []
28+
},
29+
"_help_format": "Options affecting formatting.",
30+
"format": {
31+
"_help_line_width": [
32+
"How wide to allow formatted cmake files"
33+
],
34+
"line_width": 80,
35+
"_help_tab_size": [
36+
"How many spaces to tab for indent"
37+
],
38+
"tab_size": 2,
39+
"_help_max_subgroups_hwrap": [
40+
"If an argument group contains more than this many sub-groups",
41+
"(parg or kwarg groups) then force it to a vertical layout."
42+
],
43+
"max_subgroups_hwrap": 2,
44+
"_help_max_pargs_hwrap": [
45+
"If a positional argument group contains more than this many",
46+
"arguments, then force it to a vertical layout."
47+
],
48+
"max_pargs_hwrap": 6,
49+
"_help_max_rows_cmdline": [
50+
"If a cmdline positional group consumes more than this many",
51+
"lines without nesting, then invalidate the layout (and nest)"
52+
],
53+
"max_rows_cmdline": 2,
54+
"_help_separate_ctrl_name_with_space": [
55+
"If true, separate flow control names from their parentheses",
56+
"with a space"
57+
],
58+
"separate_ctrl_name_with_space": false,
59+
"_help_separate_fn_name_with_space": [
60+
"If true, separate function names from parentheses with a",
61+
"space"
62+
],
63+
"separate_fn_name_with_space": false,
64+
"_help_dangle_parens": [
65+
"If a statement is wrapped to more than one line, than dangle",
66+
"the closing parenthesis on its own line."
67+
],
68+
"dangle_parens": false,
69+
"_help_dangle_align": [
70+
"If the trailing parenthesis must be 'dangled' on its on",
71+
"line, then align it to this reference: `prefix`: the start",
72+
"of the statement, `prefix-indent`: the start of the",
73+
"statement, plus one indentation level, `child`: align to",
74+
"the column of the arguments"
75+
],
76+
"dangle_align": "prefix",
77+
"_help_min_prefix_chars": [
78+
"If the statement spelling length (including space and",
79+
"parenthesis) is smaller than this amount, then force reject",
80+
"nested layouts."
81+
],
82+
"min_prefix_chars": 4,
83+
"_help_max_prefix_chars": [
84+
"If the statement spelling length (including space and",
85+
"parenthesis) is larger than the tab width by more than this",
86+
"amount, then force reject un-nested layouts."
87+
],
88+
"max_prefix_chars": 10,
89+
"_help_max_lines_hwrap": [
90+
"If a candidate layout is wrapped horizontally but it exceeds",
91+
"this many lines, then reject the layout."
92+
],
93+
"max_lines_hwrap": 2,
94+
"_help_line_ending": [
95+
"What style line endings to use in the output."
96+
],
97+
"line_ending": "unix",
98+
"_help_command_case": [
99+
"Format command names consistently as 'lower' or 'upper' case"
100+
],
101+
"command_case": "canonical",
102+
"_help_keyword_case": [
103+
"Format keywords consistently as 'lower' or 'upper' case"
104+
],
105+
"keyword_case": "unchanged",
106+
"_help_always_wrap": [
107+
"A list of command names which should always be wrapped"
108+
],
109+
"always_wrap": [],
110+
"_help_enable_sort": [
111+
"If true, the argument lists which are known to be sortable",
112+
"will be sorted lexicographicall"
113+
],
114+
"enable_sort": true,
115+
"_help_autosort": [
116+
"If true, the parsers may infer whether or not an argument",
117+
"list is sortable (without annotation)."
118+
],
119+
"autosort": false,
120+
"_help_require_valid_layout": [
121+
"By default, if cmake-format cannot successfully fit",
122+
"everything into the desired linewidth it will apply the",
123+
"last, most aggressive attempt that it made. If this flag is",
124+
"True, however, cmake-format will print error, exit with non-",
125+
"zero status code, and write-out nothing"
126+
],
127+
"require_valid_layout": false,
128+
"_help_layout_passes": [
129+
"A dictionary mapping layout nodes to a list of wrap",
130+
"decisions. See the documentation for more information."
131+
],
132+
"layout_passes": {}
133+
},
134+
"_help_markup": "Options affecting comment reflow and formatting.",
135+
"markup": {
136+
"_help_bullet_char": [
137+
"What character to use for bulleted lists"
138+
],
139+
"bullet_char": "*",
140+
"_help_enum_char": [
141+
"What character to use as punctuation after numerals in an",
142+
"enumerated list"
143+
],
144+
"enum_char": ".",
145+
"_help_first_comment_is_literal": [
146+
"If comment markup is enabled, don't reflow the first comment",
147+
"block in each listfile. Use this to preserve formatting of",
148+
"your copyright/license statements."
149+
],
150+
"first_comment_is_literal": false,
151+
"_help_literal_comment_pattern": [
152+
"If comment markup is enabled, don't reflow any comment block",
153+
"which matches this (regex) pattern. Default is `None`",
154+
"(disabled)."
155+
],
156+
"literal_comment_pattern": null,
157+
"_help_fence_pattern": [
158+
"Regular expression to match preformat fences in comments",
159+
"default= ``r'^\\s*([`~]{3}[`~]*)(.*)$'``"
160+
],
161+
"fence_pattern": "^\\s*([`~]{3}[`~]*)(.*)$",
162+
"_help_ruler_pattern": [
163+
"Regular expression to match rulers in comments default=",
164+
"``r'^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'``"
165+
],
166+
"ruler_pattern": "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$",
167+
"_help_explicit_trailing_pattern": [
168+
"If a comment line matches starts with this pattern then it",
169+
"is explicitly a trailing comment for the preceding",
170+
"argument. Default is '#<'"
171+
],
172+
"explicit_trailing_pattern": "#<",
173+
"_help_hashruler_min_length": [
174+
"If a comment line starts with at least this many consecutive",
175+
"hash characters, then don't lstrip() them off. This allows",
176+
"for lazy hash rulers where the first hash char is not",
177+
"separated by space"
178+
],
179+
"hashruler_min_length": 10,
180+
"_help_canonicalize_hashrulers": [
181+
"If true, then insert a space between the first hash char and",
182+
"remaining hash chars in a hash ruler, and normalize its",
183+
"length to fill the column"
184+
],
185+
"canonicalize_hashrulers": true,
186+
"_help_enable_markup": [
187+
"enable comment markup parsing and reflow"
188+
],
189+
"enable_markup": true
190+
},
191+
"_help_lint": "Options affecting the linter",
192+
"lint": {
193+
"_help_disabled_codes": [
194+
"a list of lint codes to disable"
195+
],
196+
"disabled_codes": [],
197+
"_help_function_pattern": [
198+
"regular expression pattern describing valid function names"
199+
],
200+
"function_pattern": "[0-9a-z_]+",
201+
"_help_macro_pattern": [
202+
"regular expression pattern describing valid macro names"
203+
],
204+
"macro_pattern": "[0-9A-Z_]+",
205+
"_help_global_var_pattern": [
206+
"regular expression pattern describing valid names for",
207+
"variables with global (cache) scope"
208+
],
209+
"global_var_pattern": "[A-Z][0-9A-Z_]+",
210+
"_help_internal_var_pattern": [
211+
"regular expression pattern describing valid names for",
212+
"variables with global scope (but internal semantic)"
213+
],
214+
"internal_var_pattern": "_[A-Z][0-9A-Z_]+",
215+
"_help_local_var_pattern": [
216+
"regular expression pattern describing valid names for",
217+
"variables with local scope"
218+
],
219+
"local_var_pattern": "[a-z][a-z0-9_]+",
220+
"_help_private_var_pattern": [
221+
"regular expression pattern describing valid names for",
222+
"privatedirectory variables"
223+
],
224+
"private_var_pattern": "_[0-9a-z_]+",
225+
"_help_public_var_pattern": [
226+
"regular expression pattern describing valid names for public",
227+
"directory variables"
228+
],
229+
"public_var_pattern": "[A-Z][0-9A-Z_]+",
230+
"_help_argument_var_pattern": [
231+
"regular expression pattern describing valid names for",
232+
"function/macro arguments and loop variables."
233+
],
234+
"argument_var_pattern": "[a-z][a-z0-9_]+",
235+
"_help_keyword_pattern": [
236+
"regular expression pattern describing valid names for",
237+
"keywords used in functions or macros"
238+
],
239+
"keyword_pattern": "[A-Z][0-9A-Z_]+",
240+
"_help_max_conditionals_custom_parser": [
241+
"In the heuristic for C0201, how many conditionals to match",
242+
"within a loop in before considering the loop a parser."
243+
],
244+
"max_conditionals_custom_parser": 2,
245+
"_help_min_statement_spacing": [
246+
"Require at least this many newlines between statements"
247+
],
248+
"min_statement_spacing": 1,
249+
"_help_max_statement_spacing": [
250+
"Require no more than this many newlines between statements"
251+
],
252+
"max_statement_spacing": 2,
253+
"max_returns": 6,
254+
"max_branches": 12,
255+
"max_arguments": 5,
256+
"max_localvars": 15,
257+
"max_statements": 50
258+
},
259+
"_help_encode": "Options affecting file encoding",
260+
"encode": {
261+
"_help_emit_byteorder_mark": [
262+
"If true, emit the unicode byte-order mark (BOM) at the start",
263+
"of the file"
264+
],
265+
"emit_byteorder_mark": false,
266+
"_help_input_encoding": [
267+
"Specify the encoding of the input file. Defaults to utf-8"
268+
],
269+
"input_encoding": "utf-8",
270+
"_help_output_encoding": [
271+
"Specify the encoding of the output file. Defaults to utf-8.",
272+
"Note that cmake only claims to support utf-8 so be careful",
273+
"when using anything else"
274+
],
275+
"output_encoding": "utf-8"
276+
},
277+
"_help_misc": "Miscellaneous configurations options.",
278+
"misc": {
279+
"_help_per_command": [
280+
"A dictionary containing any per-command configuration",
281+
"overrides. Currently only `command_case` is supported."
282+
],
283+
"per_command": {}
284+
}
285+
}

.pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ repos:
3333
- id: codespell
3434
additional_dependencies: [tomli]
3535

36+
- repo: https://github.com/cheshirekow/cmake-format-precommit
37+
rev: v0.6.10
38+
hooks:
39+
- id: cmake-format
40+
files: CMakeLists\.txt$|\.cmake$
41+
- id: cmake-lint
42+
files: CMakeLists\.txt$|\.cmake$
43+
3644
- repo: local
3745
hooks:
3846
- id: copyright-headers

0 commit comments

Comments
 (0)