Scroll to navigation

cmake-format(1) General Commands Manual cmake-format(1)

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.

Formatting is configurable by providing a configuration file. The configuration
file can be in json, yaml, or python format. 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 it's
parent directory up to the root of the filesystem. It will return the first
file it finds with a filename that matches '\.?cmake-format(.yaml|.json|.py)'.

cmake-format can spit out the default configuration for you as starting point
for customization. Run with `--dump-config [yaml|json|python]`.

OPTIONS

show program's version number and exit

If specified, print the default configuration to stdout and exit

When used with --dump-config, will omit helptext comments in the output

When used with --dump-config, will omit any unmodified configuration value.

Exit with status code 0 if formatting would not change file contents, or status code 1 if it would

Where to write the formatted file. Default is stdout.

path to configuration file(s)

Specify variable tags.

Specify property tags.

Disable formatting entirely, making cmake-format a no-op

How wide to allow formatted cmake files

How many spaces to tab for indent

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>

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

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

If a positional argument group contains more than this many arguments, then force it to a vertical layout.

If a cmdline positional group consumes more than this many lines without nesting, then invalidate the layout (and nest)

If true, separate flow control names from their parentheses with a space

If true, separate function names from parentheses with a space

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

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

If the statement spelling length (including space and parenthesis) is smaller than this amount, then force reject nested layouts.

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.

If a candidate layout is wrapped horizontally but it exceeds this many lines, then reject the layout.

What style line endings to use in the output.

Format command names consistently as 'lower' or 'upper' case

Format keywords consistently as 'lower' or 'upper' case

A list of command names which should always be wrapped

If true, the argument lists which are known to be sortable will be sorted lexicographicall

If true, the parsers may infer whether or not an argument list is sortable (without annotation).

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

What character to use for bulleted lists

What character to use as punctuation after numerals in an enumerated list

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.

If comment markup is enabled, don't reflow any comment block which matches this (regex) pattern. Default is `None` (disabled).

Regular expression to match preformat fences in comments default= ``r'^\s*([`~]{3}[`~]*)(.*)$'``

Regular expression to match rulers in comments default= ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``

If a comment line matches starts with this pattern then it is explicitly a trailing comment for the preceding argument. Default is '#<'

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

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 comment markup parsing and reflow

a list of lint codes to disable

regular expression pattern describing valid function names

regular expression pattern describing valid macro names

regular expression pattern describing valid names for variables with global (cache) scope

regular expression pattern describing valid names for variables with global scope (but internal semantic)

regular expression pattern describing valid names for variables with local scope

regular expression pattern describing valid names for privatedirectory variables

regular expression pattern describing valid names for public directory variables

regular expression pattern describing valid names for function/macro arguments and loop variables.

regular expression pattern describing valid names for keywords used in functions or macros

In the heuristic for C0201, how many conditionals to match within a loop in before considering the loop a parser.

Require at least this many newlines between statements

Require no more than this many newlines between statements

If true, emit the unicode byte-order mark (BOM) at the start of the file

Specify the encoding of the input file. Defaults to utf-8

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

AUTHORS

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

DISTRIBUTION

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

Manual