Skip to content

Commit 7afcd33

Browse files
committed
refactor(cmake): CMake configuration files for improved readability and consistency
1 parent b4bc86c commit 7afcd33

File tree

13 files changed

+783
-573
lines changed

13 files changed

+783
-573
lines changed

.cmake-format.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# cmake-format configuration file
19+
20+
# -----------------------------
21+
# Options affecting formatting.
22+
# -----------------------------
23+
with section("format"):
24+
# How wide to allow formatted cmake files
25+
line_width = 90
26+
27+
# How many spaces to tab for indent
28+
tab_size = 2
29+
30+
# If a positional argument group contains more than this many arguments,
31+
# then force it to a vertical layout.
32+
max_pargs_hwrap = 4
33+
34+
# If the statement spelling length (including space and parenthesis) is
35+
# smaller than this amount, then force reject nested layouts.
36+
# This value only comes into play when considering whether or not to nest
37+
# arguments below their parent. If the number of characters in the parent
38+
# is less than this value, we will not nest.
39+
min_prefix_chars = 32
40+
41+
# If true, separate flow control names from their parentheses with a space
42+
separate_ctrl_name_with_space = False
43+
44+
# If true, separate function names from parentheses with a space
45+
separate_fn_name_with_space = False
46+
47+
# If a statement is wrapped to more than one line, than dangle the closing
48+
# parenthesis on it's own line
49+
dangle_parens = False
50+
51+
# What style line endings to use in the output.
52+
line_ending = "unix"
53+
54+
# Format command names consistently as 'lower' or 'upper' case
55+
command_case = "lower"
56+
57+
# Format keywords consistently as 'lower' or 'upper' case
58+
keyword_case = "unchanged"
59+
60+
# ------------------------------------------------
61+
# Options affecting comment reflow and formatting.
62+
# ------------------------------------------------
63+
with section("markup"):
64+
# enable comment markup parsing and reflow
65+
enable_markup = False
66+
67+
# If comment markup is enabled, don't reflow the first comment block in
68+
# eachlistfile. Use this to preserve formatting of your
69+
# copyright/licensestatements.
70+
first_comment_is_literal = True
71+
72+
# If comment markup is enabled, don't reflow any comment block which
73+
# matches this (regex) pattern. Default is `None` (disabled).
74+
literal_comment_pattern = None

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ jobs:
116116
exit -1
117117
fi
118118
119+
- name: cmake-format check
120+
run: |
121+
pre-commit run cmake-format -a
122+
119123
- name: Build Docs
120124
working-directory: "cpp/build"
121125
run: |

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ repos:
4747
types_or: [c++]
4848
args: [--style=file, --verbose]
4949
exclude: ^cpp/thirdparty/
50+
51+
- repo: https://github.com/cheshirekow/cmake-format-precommit
52+
rev: v0.6.10
53+
hooks:
54+
- id: cmake-format
5055

5156
- repo: https://github.com/pocc/pre-commit-hooks
5257
rev: v1.3.5

0 commit comments

Comments
 (0)