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