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

Dmitriy Ovdienko dmitriy.ovdienko at gmail.com
Thu Mar 5 10:21:37 EST 2009


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