Skip to content

Latest commit

 

History

History
375 lines (137 loc) · 8.11 KB

README.md

File metadata and controls

375 lines (137 loc) · 8.11 KB

Functions

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...

Datatypes

  • <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

Function List

Function Descriptions

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

is the same as function_capture. deprecate one of the two

binds variables to the function by caputring their current value and storing them let funcA : ()->res bind(funcA var1 var2) will store var1 and var2 and provide them to the funcA call

call

dynamic function call method can call the following

  • a cmake macro or function
  • a cmake file containing a single function
  • a lambda expression (see lambda())
  • a object with call operation defined
  • a property reference ie this.method() CANNOT call
  • a navigation path no output except through return values or referneces

check_function

curry_compile_encoded_list

define_function

function_capture

function_define_new

function_help

function_import

function_import_dispatcher

function_import_table

imports the specified map as a function table which is callable via <function_name> whis is a performance enhancement

function_lines_get

returns the function content in a list of lines. cmake does nto support a list containing a strings which in return contain semicolon the workaround is that all semicolons in the source are replaced by a separate line containsing the string ![[[SEMICOLON]]] so the number of lines a function has is the number of lines minus the number of lines containsing only ![[[SEMICOLON]]]

function_new

creates a and defines a function (with random name)

function_parse

function_signature_get

function_signature_regex

function_string_get

returns the implementation of the function (a string containing the source code) this only works for functions files and function strings. CMake does not offer a possibility to get the implementation of a defined function or macro.

function_string_import

function_string_rename

injects code into function (right after function is called) and returns result

invocation_arguments_sequence

invocation_argument_encoded_list

invocation_argument_string

is_anonymous_function

is_function

returns true if the the val is a function string or a function file

is_function_cmake

is_function_file

is_function_ref

is_function_string

returns true if the the string val is a function

load_function

reads a functions and returns it

rcall

allows a single line call with result ie rcall(some_result = obj.getSomeInfo(arg1 arg2))

save_function

try_call

wrap_platform_specific_function