[CMake] Strangeness with ARGVn variables

Zachary Pincus zpincus at stanford.edu
Wed Jan 25 21:37:05 EST 2006


Hi folks,

I'm having some strange issues using the ARGVn variables in macros.  
Specifically, even when one of those variables has a value, they seem  
to fail IF tests (and similar).

Perhaps this is best illustrated with an example:
#----------
MACRO(foo)
   IF(ARGV0)
     MESSAGE("ONE ARGUMENT")
   ELSE(ARGV0)
     MESSAGE("NO ARGUMENTS")
   ENDIF(ARGV0)
ENDMACRO(foo)

foo()
foo(a)
#----------

gives the following output (using a CVS checkout of CMake from  
earlier this month)
NO ARGUMENTS
NO ARGUMENTS

This does not seem to be correct!
However, if I trivially modify the macro:
#----------
MACRO(foo)
SET(bar "${ARGV0}")
IF(bar)
   MESSAGE("ONE ARGUMENT")
ELSE(bar)
   MESSAGE("NO ARGUMENTS")
ENDIF(bar)
ENDMACRO(foo)

foo()
foo(a)
#----------

we get the output
NO ARGUMENTS
ONE ARGUMENT
as expected.

Any thoughts?

Zach


More information about the CMake mailing list