.
. RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .rstReportMargin post:
.. . RE indent \\n[an-margin]
old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1 new: \\n[rst2man-indent\\n[rst2man-indent-level]]
..
file ::= \%file_element* file_element ::= \%command_invocation \%line_ending | (\%bracket_comment|\%space)* \%line_ending line_ending ::= \%line_comment? \%newline space ::= <match \(aq[ \et]+\(aq> newline ::= <match \(aq\en\(aq>Note that any source file line not inside \%Command Arguments or a \%Bracket Comment can end in a \%Line Comment.
command_invocation ::= \%space* \%identifier \%space* \(aq(\(aq \%arguments \(aq)\(aq identifier ::= <match \(aq[A-Za-z_][A-Za-z0-9_]*\(aq> arguments ::= \%argument? \%separated_arguments* separated_arguments ::= \%separation+ \%argument? | \%separation* \(aq(\(aq \%arguments \(aq)\(aq separation ::= \%space | \%line_endingFor example: NDENT 0.0 NDENT 3.5
add_executable(hello world.c)NINDENT NINDENT Command names are case-insensitive. Nested unquoted parentheses in the arguments must balance. Each ( or ) is given to the command invocation as a literal \%Unquoted Argument. This may be used in calls to the if() command to enclose conditions. For example: NDENT 0.0 NDENT 3.5
if(FALSE AND (FALSE OR TRUE)) # evaluates to FALSENINDENT NINDENT NOTE: NDENT 0.0 NDENT 3.5 CMake versions prior to 3.0 require command name identifiers to be at least 2 characters. CMake versions prior to 2.8.12 silently accept an \%Unquoted Argument or a \%Quoted Argument immediately following a \%Quoted Argument and not separated by any whitespace. For compatibility, CMake 2.8.12 and higher accept such code but produce a warning. NINDENT NINDENT
argument ::= \%bracket_argument | \%quoted_argument | \%unquoted_argument
bracket_argument ::= \%bracket_open \%bracket_content \%bracket_close bracket_open ::= \(aq[\(aq \(aq=\(aq{len} \(aq[\(aq bracket_content ::= <any text not containing a \%bracket_close of the same {len} as the \%bracket_open> bracket_close ::= \(aq]\(aq \(aq=\(aq{len} \(aq]\(aqAn opening bracket of length len >= 0 is written [ followed by len = followed by [ and the corresponding closing bracket is written ] followed by len = followed by ]. Brackets do not nest. A unique length may always be chosen for the opening and closing brackets to contain closing brackets of other lengths. Bracket argument content consists of all text between the opening and closing brackets, except that one newline immediately following the opening bracket, if any, is ignored. No evaluation of the enclosed content, such as \%Escape Sequences or \%Variable References, is performed. A bracket argument is always given to the command invocation as exactly one argument. For example: NDENT 0.0 NDENT 3.5
message([=[ This is the first line in a bracket argument with bracket length 1. No \e-escape sequences or ${variable} references are evaluated. This is always one argument even though it contains a ; character. The text does not end on a closing bracket of length 0 like ]]. It does end in a closing bracket of length 1. ]=])NINDENT NINDENT NOTE: NDENT 0.0 NDENT 3.5 CMake versions prior to 3.0 do not support bracket arguments. They interpret the opening bracket as the start of an \%Unquoted Argument. NINDENT NINDENT
quoted_argument ::= \(aq"\(aq \%quoted_element* \(aq"\(aq quoted_element ::= <any character except \(aq\e\(aq or \(aq"\(aq> | \%escape_sequence | \%quoted_continuation quoted_continuation ::= \(aq\e\(aq \%newlineQuoted argument content consists of all text between opening and closing quotes. Both \%Escape Sequences and \%Variable References are evaluated. A quoted argument is always given to the command invocation as exactly one argument. For example: NDENT 0.0 NDENT 3.5
message("This is a quoted argument containing multiple lines. This is always one argument even though it contains a ; character. Both \e\e-escape sequences and ${variable} references are evaluated. The text does not end on an escaped double-quote like \e". It does end in an unescaped double quote. ")NINDENT NINDENT The final \e on any line ending in an odd number of backslashes is treated as a line continuation and ignored along with the immediately following newline character. For example: NDENT 0.0 NDENT 3.5
message("\e This is the first line of a quoted argument. \e In fact it is the only line but since it is long \e the source code uses line continuation.\e ")NINDENT NINDENT NOTE: NDENT 0.0 NDENT 3.5 CMake versions prior to 3.0 do not support continuation with \e. They report errors in quoted arguments containing lines ending in an odd number of \e characters. NINDENT NINDENT
unquoted_argument ::= \%unquoted_element+ | \%unquoted_legacy unquoted_element ::= <any character except whitespace or one of \(aq()#"\e\(aq> | \%escape_sequence unquoted_legacy ::= <see note in text>Unquoted argument content consists of all text in a contiguous block of allowed or escaped characters. Both \%Escape Sequences and \%Variable References are evaluated. The resulting value is divided in the same way \%Lists divide into elements. Each non-empty element is given to the command invocation as an argument. Therefore an unquoted argument may be given to a command invocation as zero or more arguments. For example: NDENT 0.0 NDENT 3.5
foreach(arg NoSpace Escaped\e Space This;Divides;Into;Five;Arguments Escaped\e;Semicolon ) message("${arg}") endforeach()NINDENT NINDENT NOTE: NDENT 0.0 NDENT 3.5 To support legacy CMake code, unquoted arguments may also contain double-quoted strings ("...", possibly enclosing horizontal whitespace), and make-style variable references ($(MAKEVAR)). Unescaped double-quotes must balance, may not appear at the beginning of an unquoted argument, and are treated as part of the content. For example, the unquoted arguments -Da="b c", -Da=$(v), and a" "b"c"d are each interpreted literally. The above "unquoted_legacy" production represents such arguments. We do not recommend using legacy unquoted arguments in new code. Instead use a \%Quoted Argument or a \%Bracket Argument to represent the content. NINDENT NINDENT
escape_sequence ::= \%escape_identity | \%escape_encoded | \%escape_semicolon escape_identity ::= \(aq\e\(aq <match \(aq[^A-Za-z0-9;]\(aq> escape_encoded ::= \(aq\et\(aq | \(aq\er\(aq | \(aq\en\(aq escape_semicolon ::= \(aq\e;\(aqA \e followed by a non-alphanumeric character simply encodes the literal character without interpreting it as syntax. A \et, \er, or \en encodes a tab, carriage return, or newline character, respectively. A \e; outside of any \%Variable References encodes itself but may be used in an \%Unquoted Argument to encode the ; without dividing the argument value on it. A \e; inside \%Variable References encodes the literal ; character. (See also policy CMP0053 documentation for historical considerations.)
bracket_comment ::= \(aq#\(aq \%bracket_argumentFor example: NDENT 0.0 NDENT 3.5
#[[This is a bracket comment. It runs until the close bracket.]] message("First Argument\en" #[[Bracket Comment]] "Second Argument")NINDENT NINDENT NOTE: NDENT 0.0 NDENT 3.5 CMake versions prior to 3.0 do not support bracket comments. They interpret the opening # as the start of a \%Line Comment. NINDENT NINDENT
line_comment ::= \(aq#\(aq <any text not starting in a \%bracket_argument and not containing a \%newline>For example: NDENT 0.0 NDENT 3.5
# This is a line comment. message("First Argument\en" # This is a line comment :) "Second Argument") # This is a line comment.NINDENT NINDENT
Function Scope \%Command Definitions created by the function() command create commands that, when invoked, process the recorded commands in a new variable binding scope. A variable "set" or "unset" binds in this scope and is visible for the current function and any nested calls, but not after the function returns.
Directory Scope Each of the \%Directories in a source tree has its own variable bindings. Before processing the CMakeLists.txt file for a directory, CMake copies all variable bindings currently defined in the parent directory, if any, to initialize the new directory scope. CMake \%Scripts, when processed with cmake -P, bind variables in one "directory" scope. A variable "set" or "unset" not inside a function call binds to the current directory scope.
Persistent Cache CMake stores a separate set of "cache" variables, or "cache entries", whose values persist across multiple runs within a project build tree. Cache entries have an isolated binding scope modified only by explicit request, such as by the CACHE option of the set() and unset() commands. NINDENT When evaluating \%Variable References, CMake first searches the function call stack, if any, for a binding and then falls back to the binding in the current directory scope, if any. If a "set" binding is found, its value is used. If an "unset" binding is found, or no binding is found, CMake then searches for a cache entry. If a cache entry is found, its value is used. Otherwise, the variable reference evaluates to an empty string. The cmake-variables(7) manual documents many variables that are provided by CMake or have meaning to CMake when set by project code.
set(srcs a.c b.c c.c) # sets "srcs" to "a.c;b.c;c.c"NINDENT NINDENT Lists are meant for simple use cases such as a list of source files and should not be used for complex data processing tasks. Most commands that construct lists do not escape ; characters in list elements, thus flattening nested lists: NDENT 0.0 NDENT 3.5
set(x a "b;c") # sets "x" to "a;b;c", not "a;b\e;c"NINDENT NINDENT
.