Skip to content

Commit

Permalink
Use cmake-format for enforcing uniform formatting in CMake files (kok…
Browse files Browse the repository at this point in the history
…kos#7356)

This applies and enforces CMake formatting.
  • Loading branch information
masterleinad authored Sep 28, 2024
1 parent ab9a637 commit 0247634
Show file tree
Hide file tree
Showing 95 changed files with 4,953 additions and 5,326 deletions.
28 changes: 28 additions & 0 deletions .cmake-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -----------------------------
# Options affecting formatting.
# -----------------------------
with section("format"):

# How wide to allow formatted cmake files
line_width = 120

# If an argument group contains more than this many sub-groups (parg or kwarg
# groups) then force it to a vertical layout.
max_subgroups_hwrap = 3

# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on its own line.
dangle_parens = True

# If the trailing parenthesis must be 'dangled' on its on line, then align it
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
# the start of the statement, plus one indentation level, `child`: align to
# the column of the arguments
dangle_align = 'prefix'

# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):
# enable comment markup parsing and reflow
enable_markup = False
2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
permissions: read-all

jobs:
formatting-check:
clang-formatting-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/cmake-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: cmake-format check

on: [push, pull_request]

permissions: read-all

jobs:
cmake-formatting-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: cmake-format lint action
uses: puneetmatharu/cmake-format-lint-action@efbb497b2a8badd2c9dc638faaf8ef4a9aa71bc8 # v1.0.4
with:
args: --config-files .cmake-format.py --in-place
- name: check
run: git diff --exit-code
Loading

0 comments on commit 0247634

Please sign in to comment.