[CMake] Call a macro through a variable. Possible or not?

Dmitriy Ovdienko dmitriy.ovdienko at gmail.com
Fri Mar 6 05:05:38 EST 2009


Marcel,

I'm sorry. I supposed there is special command "command" to invoke
code stored to variable.

I reread manual once more and did not find anything like
meta-programing for CMake.

BTW, why do you need this feature?

Regards,
Dmitriy

Friday, March 6, 2009, 10:37:37 AM, you wrote:

ML> Thanks for your reply Dmitriy,

ML> but... it does not solve what I wanted to do.

ML> If I understand the syntax page correctly, it says you can invoke the
ML> macro/function named command and pass arguments stored in variable Foo
ML> using the syntax command(${Foo}).

ML> But that's not what I meant. I was looking for a way to construct, on
ML> the fly, a "meta-command" that would consist of a sequence of
ML> macro/function calls. So, for example, suppose my meta-command is named
ML> Foo, and I have three macros named a, b, and c. Then 'set(Foo a b c)'
ML> would create my meta-command Foo, which when *executed* -- and the
ML> question is: is this possible? -- causes the macros/functions a, b, and
ML> c to be called in succession.

ML> So, the question remains, whether it's possible to do something I wrote
ML> in my original post; i.e., invoking the macro do_it, through a variable
ML> cmd that is holding the value 'do_it'.

ML> Kind regards,
ML> Marcel Loose.

ML> On Thu, 2009-03-05 at 17:21 +0200, Dmitriy Ovdienko wrote:
>> Hello Marcel,
>> 
>> Quote from http://cmake.org/cmake/help/syntax.html
>> 
>> 
>> CMake supports simple variables that can be either strings or lists of strings.
>> Variables are referenced using a ${VAR} syntax. Multiple arguments can be grouped
>> together into a list using the set command. All other commands expand the lists as
>> if they had been passed into the command with white-space separation. For example,
>> 
>>   set(Foo a b c)
>> 
>> will result in setting the variable Foo to a b c, and if Foo is passed into another command
>> 
>>   command(${Foo})
>> 
>> 
>> Thursday, March 5, 2009, 2:19:34 PM, you wrote:
>> 
>> ML> Hi,
>> 
>> ML> I was wondering whether it's possible to invoke a macro through a
>> ML> variable. The variable contains a command (or list of commands) to be
>> ML> invoked.
>> 
>> ML> For example:
>> 
>> ML> macro(do_it)
>> ML>   message(STATUS "do_it")
>> ML> endmacro(do_it)
>> 
>> ML> set(cmd do_it)
>> ML> ${cmd}()      # <-- This doesn't work, but is there a way to do this?
>> 
>> ML> Best regards,
>> ML> Marcel Loose
>> 
>> 
>> ML> _______________________________________________
>> ML> Powered by www.kitware.com
>> 
>> ML> Visit other Kitware open-source projects at
>> ML> http://www.kitware.com/opensource/opensource.html
>> 
>> ML> Please keep messages on-topic and check the CMake FAQ at:
>> ML> http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> ML> Follow this link to subscribe/unsubscribe:
>> ML> http://www.cmake.org/mailman/listinfo/cmake
>> 
>> 
>> 




-- 
Best regards,
 Dmitriy                            mailto:dmitriy.ovdienko at gmail.com



More information about the CMake mailing list