Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Summary: configure cmake-format (from https://pypi.org/project/cmakelang/) to
# apply a consistent style to CMakeLists.txt and *.cmake files. For readability
# and maintainability, the Quantumlib style diverges slightly from the defaults,
# specifically in (1) using 4-space indent, (2) how splitting across lines is
# done, and (3) putting the closing paren on a separate line when splitting.

format:
line_width: 80
tab_size: 4
use_tabchars: false

# If a stmt is split across lines, put the closing paren on its own line.
dangle_parens: true

# Properties that control splitting statements across multiple lines. From the
# cmake-format docs, I couldn't understand how they interacted, so these
# values were obtained empirically by varying the values until the output
# produced by cmake-format was acceptable.
max_pargs_hwrap: 4
max_rows_cmdline: 2
max_subgroups_hwrap: 1
max_prefix_chars: 24
min_prefix_chars: 4

parse:
additional_commands:
# The following commands (project, set, etc.) are standard CMake commands,
# not additions; their presence here overrides cmake-format's default
# behavior for them because the default resulted in awkward splits.
project:
flags:
kwargs:
set:
flags:
- CACHE
- ENV
- FORCE
- HELP
- TYPE
- VALUE
kwargs:
message:
flags:
- AUTHOR_WARNING
- DEBUG
- DEPRECATION
- FATAL_ERROR
- NOTICE
- SEND_ERROR
- STATUS
- TRACE
- VERBOSE
- WARNING

markup:
# Don't reformat comments.
enable_markup: false
Loading