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

Fernando Cacciola fernando.cacciola at gmail.com
Fri Feb 22 09:52:22 EST 2008


Sylvain Benner wrote:

> Hi,
>
> You should use IF(VAR) instead.
>
!! Of course !!

I got confused because what I really tried at first, but didn't work, was 
this:

if ( $ENV{SOME_ENV_VAR} )

so I figured I needed to "load" the enviroment variable into a cmake 
variable first, for which I added:

set ( SOME_ENV_VAR $ENV{SOME_ENV_VAR} )

but then I changed the IF() and forgot the strip out the ${} and got totally 
mindblocked...

Now, why didn't

if ( $ENV{SOME_ENV_VAR} )

work?

Yes, the variable is defined as I can see when I (correctly) test it's cmake 
counterpart.

TIA

Fernando











> In your example you made the test :  IF(whatever)
> "whatever" variable does not exist so the evaluation is false.
>
> --Sylvain 




More information about the CMake mailing list