AW: [CMake] IF( ${VAR} ) behaviour

Gerhard Grimm ggrimm at detec.de
Fri Feb 22 08:38:44 EST 2008


Hi Fernando,

the code lines

set ( VAR "whatever" )

if ( ${VAR} )

result in the "IF" command testing the variable "whatever" -
which has not been set and thus evaluates to false.
You probably wanted to use

if ( VAR )

to evaluate the status of VAR.

Regards, Gerhard

-----Ursprüngliche Nachricht-----
Gesendet: Freitag, 22. Februar 2008 15:28
An: cmake at cmake.org
Betreff: [CMake] IF( ${VAR} ) behaviour


Hi people,

Consider the following (tested in 2.4.7):

set ( VAR "whatever" )

message( STATUS "VAR=${VAR}" )

if   ( ${VAR} )
  message( STATUS "VAR evaluates to true" )
else ( ${VAR} )
  message( STATUS "VAR evaluates to false" )
endif( ${VAR} )


it prints "VAR evaluates to false".

Is that expected??  The documentation of IF() doesn't match this behaviour 
AFAICS.

TIA


-- 

Fernando Cacciola
SciSoft
http://fcacciola.50webs.com
http://groups.google.com/group/cppba


More information about the CMake mailing list