tags:

views:

437

answers:

2

I want to create a macro whose argument is optional. If not specified, the argument's value should be an empty string. How can I do this? Thanks for your help.

A: 

This happens by default if the argument isn't specified as CMake doesn't check the number of parameters required for a macro.

Mike McQuaid
+2  A: 

CMake does not (AFAIK) check the number of variables passed to a macro, so you can just go ahead and declare it as any other macro.

There is also a variable ${ARGN} which expands to a list of all the "remaining" variables passed to a macro, which may be useful.

JesperE