I'm not sure if there's a better way, but you can use configure_file
and include
here as helpers.
So, if you create an input file called "macro_helper.cmake.in" and have its contents as just the following line:
@MacroName@(MacroArg)
Then you can configure this to a per-macro output file, and simply then include
the output file:
macro(C MacroArg MacroId)
set(MacroName do_${MacroId})
# Need to make MacroArg a "proper" variable since we're in a macro, not a
# function. Run 'cmake --help-command macro' for more info.
set(MacroArg ${MacroArg})
set(OutputFile ${CMAKE_BINARY_DIR}/helpers/macro_helper_${MacroId}.cmake)
configure_file(macro_helper.cmake.in ${OutputFile} @ONLY)
include(${OutputFile})
endmacro()
Note: you don't want the comma when invoking C
- just do:
C(asdf A)