Skip to content

Commit f0a5a7a

Browse files
authored
Merge pull request #328 from szadam/rrudnicki_cmake_format
cmake format
2 parents b758327 + 5529593 commit f0a5a7a

19 files changed

+993
-509
lines changed

.cmake-format

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

.github/workflows/pr_push.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- name: Install apt packages
9595
run: |
9696
sudo apt-get update
97-
sudo apt-get install -y cmake clang-format-15 libhwloc-dev
97+
sudo apt-get install -y cmake clang-format-15 cmake-format libhwloc-dev
9898
9999
- name: Configure CMake
100100
run: >
@@ -109,6 +109,9 @@ jobs:
109109
- name: Check clang-format
110110
run: cmake --build build --target clang-format-check
111111

112+
- name: Check cmake-format
113+
run: cmake --build build --target cmake-format-check
114+
112115
DocsBuild:
113116
name: Build docs
114117
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)