Skip to content

Latest commit

 

History

History
370 lines (124 loc) · 7.75 KB

File metadata and controls

370 lines (124 loc) · 7.75 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

(<start index> <end index>)-> <cmake code>

captures the cmake code for the calling function and returns it as a string

arguments_cmake_string

recreates the invocation arguments which when evaluated are identical to the arguments passed to the function where this macro was invoked

arguments_encoded_list

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

arguments_extract

arguments_foreach

arguments_function

arguments_sequence

arguments_string

returns the argument string which was passed to the parent function it takes into considerations quoted arguments todo: start and endindex

bind

call

check_function

curry_compile_encoded_list

(["[" "]"] "(" (|)* ")" ["=>" <?func_name>() ])->

define_function

define an inline function e.g. define_function(my_func() message(hello))

function_capture

captures variables from the current scope in the function

function_define_new

(<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)

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

defines the function called ${function_name} to call an operating system specific function uses ${CMAKE_SYSTEM_NAME} to look for a function called ${function_name}${CMAKE_SYSTEM_NAME} if it exists it is wrapped itno ${function_name} else ${function_name} is defined to throw an error if it is called