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 code0if formatting would not change file contents, or status code1if 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, makingcmake-formata 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-80x09) instead of<tab_size>space characters (utf-80x20). 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-80x20). If set to`round-up`fractional indentation is replaced with a single tab character (utf-80x09) 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, ifcmake-formatcannot 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-formatwill 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'tlstrip()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 forC0201, 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 toutf-8--output-encoding OUTPUT_ENCODINGβ Specify the encoding of the output file. Defaults toutf-8. Note that cmake only claims to supportutf-8so 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
- debian bookworm: cmake-format 0.6.13-3 Β· GPL-3.0-only
- ubuntu noble: cmake-format 0.6.13-5 Β· GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms