cmake-format(1)

πŸŽ€ cmake-format β€” the manual page, but make it cute πŸŽ€

okay bestie, so this is cmake-format(1) from the General Commands Manual, and honestly? it's giving main character energy for your CMake listfiles. it parses them and formats them nicely. no cap. let's get into it πŸ’…


✨ NAME ✨

cmake-format β€” parse cmake listfiles and format them nicely.


πŸ¦‹ SYNOPSIS πŸ¦‹

cmake-format [-h] [--dump-config {yaml,json,python} | -i | -o
OUTFILE_PATH] [-c CONFIG_FILE] infilepath [infilepath ...]

πŸ’– DESCRIPTION πŸ’–

Parse cmake listfiles and format them nicely. literally that's the whole job and she ate.

Formatting is configurable by providing a configuration file. that config file can be in json, yaml, or python format, your choice, slay. 🫢

if no configuration file is specified on the command line, cmake-format will attempt to find a suitable configuration for each inputpath by checking recursively checking its parent directory up to the root of the filesystem. she will return the first file she finds with a filename that matches:

'\.?cmake-format(.yaml|.json|.py)'

and yes, she walks all the way up to the root, determined behavior, we love to see it. πŸ‘‘

cmake-format can also spit out the default configuration for you as a starting point for customization. just run with --dump-config [yaml|json|python] and take notes bestie ✨


🌸 OPTIONS 🌸

  • infilepaths β€” the input paths. she needs to know what to format.
  • -v, --version β€” show program's version number and exit
  • -l {error,warning,info,debug}, --log-level {error,warning,info,debug} β€” how chatty she is in the logs
  • --dump-config [{yaml,json,python}] β€” If specified, print the default configuration to stdout and exit
  • --dump {lex,parse,parsedb,layout,markup} β€” dump out one of those internal stages, for when you're being nosy
  • --no-help β€” When used with --dump-config, will omit helptext comments in the output
  • --no-default β€” When used with --dump-config, will omit any unmodified configuration value.
  • -i, --in-place β€” edit the file right where it lives, no separate output file
  • --check β€” Exit with status code 0 if formatting would not change file contents, or status code 1 if it would
  • -o OUTFILE_PATH, --outfile-path OUTFILE_PATH β€” Where to write the formatted file. Default is stdout.
  • -c CONFIG_FILES [CONFIG_FILES ...], --config-files CONFIG_FILES [CONFIG_FILES ...] β€” path to configuration file(s)
  • --vartags [VARTAGS ...] β€” Specify variable tags.
  • --proptags [PROPTAGS ...] β€” Specify property tags.
  • --disable [DISABLE] β€” Disable formatting entirely, making cmake-format a no-op 🫠
  • --line-width LINE_WIDTH β€” How wide to allow formatted cmake files
  • --tab-size TAB_SIZE β€” How many spaces to tab for indent
  • --use-tabchars [USE_TABCHARS] β€” If true, lines are indented using tab characters (utf-8 0x09) instead of <tab_size> space characters (utf-8 0x20). In cases where the layout would require a fractional tab character, the behavior of the fractional indentation is governed by <fractional_tab_policy>
  • --fractional-tab-policy {use-space,round-up} β€” If <use_tabchars> is True, then the value of this variable indicates how fractional indentions are handled during whitespace replacement. If set to 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set to `round-up` fractional indentation is replaced with a single tab character (utf-8 0x09) effectively shifting the column to the next tabstop
  • --max-subgroups-hwrap MAX_SUBGROUPS_HWRAP β€” If an argument group contains more than this many sub-groups (parg or kwarg groups) then force it to a vertical layout.
  • --max-pargs-hwrap MAX_PARGS_HWRAP β€” If a positional argument group contains more than this many arguments, then force it to a vertical layout.
  • --max-rows-cmdline MAX_ROWS_CMDLINE β€” If a cmdline positional group consumes more than this many lines without nesting, then invalidate the layout (and nest)
  • --separate-ctrl-name-with-space [SEPARATE_CTRL_NAME_WITH_SPACE] β€” If true, separate flow control names from their parentheses with a space
  • --separate-fn-name-with-space [SEPARATE_FN_NAME_WITH_SPACE] β€” If true, separate function names from parentheses with a space
  • --dangle-parens [DANGLE_PARENS] β€” If a statement is wrapped to more than one line, than dangle the closing parenthesis on its own line. yes she really said "dangle" πŸŽ€
  • --dangle-align {prefix,prefix-indent,child,off} β€” 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
  • --min-prefix-chars MIN_PREFIX_CHARS β€” If the statement spelling length (including space and parenthesis) is smaller than this amount, then force reject nested layouts.
  • --max-prefix-chars MAX_PREFIX_CHARS β€” If the statement spelling length (including space and parenthesis) is larger than the tab width by more than this amount, then force reject un-nested layouts.
  • --max-lines-hwrap MAX_LINES_HWRAP β€” If a candidate layout is wrapped horizontally but it exceeds this many lines, then reject the layout.
  • --line-ending {windows,unix,auto} β€” What style line endings to use in the output.
  • --command-case {lower,upper,canonical,unchanged} β€” Format command names consistently as 'lower' or 'upper' case
  • --keyword-case {lower,upper,unchanged} β€” Format keywords consistently as 'lower' or 'upper' case
  • --always-wrap [ALWAYS_WRAP ...] β€” A list of command names which should always be wrapped
  • --enable-sort [ENABLE_SORT] β€” If true, the argument lists which are known to be sortable will be sorted lexicographically
  • --autosort [AUTOSORT] β€” If true, the parsers may infer whether or not an argument list is sortable (without annotation).
  • --require-valid-layout [REQUIRE_VALID_LAYOUT] β€” By default, if cmake-format cannot successfully fit everything into the desired linewidth it will apply the last, most aggressive attempt that it made. If this flag is True, however, cmake-format will print error, exit with non-zero status code, and write-out nothing
lowkey important one, bestie: with --require-valid-layout she will not fall back to the aggressive layout β€” she errors out, exits non-zero, and writes nothing. dramatic but honest πŸ’€
  • --bullet-char BULLET_CHAR β€” What character to use for bulleted lists
  • --enum-char ENUM_CHAR β€” What character to use as punctuation after numerals in an enumerated list
  • --first-comment-is-literal [FIRST_COMMENT_IS_LITERAL] β€” If comment markup is enabled, don't reflow the first comment block in each listfile. Use this to preserve formatting of your copyright/license statements.
  • --literal-comment-pattern LITERAL_COMMENT_PATTERN β€” If comment markup is enabled, don't reflow any comment block which matches this (regex) pattern. Default is `None` (disabled).
  • --fence-pattern FENCE_PATTERN β€” Regular expression to match preformat fences in comments default= r'^\s*([`~]{3}[`~]*)(.*)$'
  • --ruler-pattern RULER_PATTERN β€” Regular expression to match rulers in comments default= r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
  • --explicit-trailing-pattern EXPLICIT_TRAILING_PATTERN β€” If a comment line matches starts with this pattern then it is explicitly a trailing comment for the preceding argument. Default is '#<'
  • --hashruler-min-length HASHRULER_MIN_LENGTH β€” If a comment line starts with at least this many consecutive hash characters, then don't lstrip() them off. This allows for lazy hash rulers where the first hash char is not separated by space
  • --canonicalize-hashrulers [CANONICALIZE_HASHRULERS] β€” If true, then insert a space between the first hash char and remaining hash chars in a hash ruler, and normalize its length to fill the column
  • --enable-markup [ENABLE_MARKUP] β€” enable comment markup parsing and reflow
  • --disabled-codes [DISABLED_CODES ...] β€” a list of lint codes to disable
  • --function-pattern FUNCTION_PATTERN β€” regular expression pattern describing valid function names
  • --macro-pattern MACRO_PATTERN β€” regular expression pattern describing valid macro names
  • --global-var-pattern GLOBAL_VAR_PATTERN β€” regular expression pattern describing valid names for variables with global (cache) scope
  • --internal-var-pattern INTERNAL_VAR_PATTERN β€” regular expression pattern describing valid names for variables with global scope (but internal semantic)
  • --local-var-pattern LOCAL_VAR_PATTERN β€” regular expression pattern describing valid names for variables with local scope
  • --private-var-pattern PRIVATE_VAR_PATTERN β€” regular expression pattern describing valid names for privatedirectory variables
  • --public-var-pattern PUBLIC_VAR_PATTERN β€” regular expression pattern describing valid names for public directory variables
  • --argument-var-pattern ARGUMENT_VAR_PATTERN β€” regular expression pattern describing valid names for function/macro arguments and loop variables.
  • --keyword-pattern KEYWORD_PATTERN β€” regular expression pattern describing valid names for keywords used in functions or macros
  • --max-conditionals-custom-parser MAX_CONDITIONALS_CUSTOM_PARSER β€” In the heuristic for C0201, how many conditionals to match within a loop in before considering the loop a parser.
  • --min-statement-spacing MIN_STATEMENT_SPACING β€” Require at least this many newlines between statements
  • --max-statement-spacing MAX_STATEMENT_SPACING β€” Require no more than this many newlines between statements
  • --max-returns MAX_RETURNS β€” cap on returns
  • --max-branches MAX_BRANCHES β€” cap on branches
  • --max-arguments MAX_ARGUMENTS β€” cap on arguments
  • --max-localvars MAX_LOCALVARS β€” cap on local variables
  • --max-statements MAX_STATEMENTS β€” cap on statements
  • --emit-byteorder-mark [EMIT_BYTEORDER_MARK] β€” If true, emit the unicode byte-order mark (BOM) at the start of the file
  • --input-encoding INPUT_ENCODING β€” Specify the encoding of the input file. Defaults to utf-8
  • --output-encoding OUTPUT_ENCODING β€” Specify the encoding of the output file. Defaults to utf-8. Note that cmake only claims to support utf-8 so be careful when using anything else
okay the encoding one is a real warning bestie, cmake only claims to support utf-8, so if you go rogue with another encoding that's on you 😭

πŸ‘‘ AUTHORS πŸ‘‘

cmake-format was written by Josh Bialkowski <josh.bialkowski@gmail.com>. king behavior fr fr 🫢


🌈 DISTRIBUTION 🌈

The latest version of cmake-format may be downloaded from https://github.com/cheshirekow/cmake_format


and that's the whole page bestie!! this was cmake-format(1) from the General Commands Manual β€” the footer just says Manual, no version, no date, just vibes β€” so go forth, format your listfiles, and be iconic πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from