I would like to create a cmake macro which fills in a given variable with some values, for example:
macro ( fillList list )
set( list a b c )
endmacro()
fillList( list )
This doesn't seem to be possible with cmake. Any suggestions for achieving this in cmake?
Return values from functions There is no built-in notion of a return value from a function. To get values out of a function, write to one of the arguments. Another issue is the variable name for the output value needs to be dereferenced before being set.
CMakeParseArguments. CMake has a predefined command to parse function and macro arguments. This command is for use in macros or functions. It processes the arguments given to that macro or function, and defines a set of variables which hold the values of the respective options.
Pass the name of the variable and use that:
macro(fillList list)
set(${list} a b c)
endmacro()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With