[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: Re: [CMake] How to test environment variable in IF command
From: Philippe Fremy <phil () freehackers ! org>
Date: 2007-07-19 13:03:02
Message-ID: 469F6106.3000703 () freehackers ! org
[Download RAW message or body]
Mike Talbot wrote:
> Hi,
>
> I'm trying to work out how to test for an environment variable in an IF
> command, the following doesn't work:
>
> SET(ENV{FOO} ON)
> MESSAGE("FOO = $ENV{FOO}") # prints "FOO = ON"
> IF(ENV{FOO})
> MESSAGE("FOO is set")
> ENDIF(ENV{FOO})
>
> Does anyone know what the right syntax for doing this is, please?
>
> Thanks,
> Mike
>
I can't tell you why because the syntax rules of CMake are still obscure
to me but this works:
SET(ENV{FOO} ON)
MESSAGE(FOO = $ENV{FOO}) # prints "FOO = ON"
SET( A $ENV{FOO} )
MESSAGE(A = ${A})
IF(A)
MESSAGE("FOO is set")
ELSE(A)
MESSAGE("FOO is not set")
ENDIF(A)
EXECUTE_PROCESS( COMMAND bash -c 'echo EDITOR=$EDITOR' )
EXECUTE_PROCESS( COMMAND bash -c 'echo FOO=$FOO' )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic