Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returning values from a cmake macro

Tags:

cmake

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?

like image 978
Paul Avatar asked Mar 10 '11 09:03

Paul


People also ask

How does CMake function return value?

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.

What is a CMake function?

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.


1 Answers

Pass the name of the variable and use that:

macro(fillList list)
  set(${list} a b c)
endmacro()
like image 198
Jack Kelly Avatar answered Sep 27 '22 22:09

Jack Kelly