CMake is a function oriented language. Every line in a cmake script is a function just a function call. It is the only available statement. CMake does not allow dynamic function calling (ie calling a function which you first know at runtime). This has problem and some further funcitonality issues are addressed in this section.
Functions in cmake are not variables - they have a separate global only scope in which they are defined.
A Note on Macros Macros are also functions. They do not have their own scope and evaluate arguments differently. They will more likely than not have unintended side effects because of the way the are evaluated. There are valid reasons to use macros but if you do not know them, you SHOULD NOT use macros...
<cmake code> ::= <string>any valid cmake code<cmake function file> ::= <cmake file>a cmake script file containing a single function<function string> :: <cmake code>a string containing a single function<cmake file> ::= <path>a file containing valid cmake code<function call> ::=<function?!>(<any...>)a function call can be evaluated to a valid cmake code line which executes the function specified<function>::=any cmake function or macro name for whichif(COMMAND )` evaluates to true. This can be directly called<function?!>::= |||<function&>||<function string&> a function?! can be any type of code which somehow evaluates to a function<function info> ::= {type:<function type>, name:<identifier>, args:<arg ...>, code:<function string>|<function call>}a map containing information on a specific function. if possible the info map contains the original source code of the function
- anonymous_function
- anonymous_function_new
- arguments_anonymous_function
- arguments_cmake_code
- arguments_cmake_string
- arguments_encoded_list
- arguments_extract
- arguments_foreach
- arguments_function
- arguments_sequence
- arguments_string
- bind
- call
- check_function
- curry_compile_encoded_list
- define_function
- function_capture
- function_define_new
- function_help
- function_import
- function_import_dispatcher
- function_import_table
- function_lines_get
- function_new
- function_parse
- function_signature_get
- function_signature_regex
- function_string_get
- function_string_import
- function_string_rename
- invocation_argument_encoded_list
- invocation_argument_string
- invocation_arguments_sequence
- is_anonymous_function
- is_function
- is_function_cmake
- is_function_file
- is_function_ref
- is_function_string
- load_function
- rcall
- save_function
- try_call
- wrap_platform_specific_function
(<start index> <end index>)-> <cmake code>
captures the cmake code for the calling function and returns it as a string
recreates the invocation arguments which when evaluated are identical to the arguments passed to the function where this macro was invoked
returns an encoded list for the specified arguments passed to current function invocation.
you can only use this inside of a cmake function and not inside a macro
returns the argument string which was passed to the parent function it takes into considerations quoted arguments todo: start and endindex
(["[" "]"] "(" (|)* ")" ["=>" <?func_name>() ])->
define an inline function
e.g. define_function(my_func() message(hello))
captures variables from the current scope in the function
(<signarture> <cmake code>)-><function name>
defines an anonymous cmake function and returns its reference (name)
the code needs to begin with the signature without the name e.g. (arg1 arg2)
defines the function called