[CMake] How to test environment variable in IF command

Mike Talbot mtalbot at abingdon.oilfield.slb.com
Thu Jul 19 06:47:09 EDT 2007


Ok - thanks, that works.

David Cole wrote:
> When dealing with ENV variable values, you should probably test their 
> contents with something like this:
>
> IF("$ENV{FOO}" STREQUAL "ON")
> ... ... ...
> ENDIF("$ENV{FOO}" STREQUAL "ON")
>
>  --- or ---
>
> SET(myFOO $ENV{FOO})
> IF(myFOO)
> ... ... ...
> ENDIF(myFOO)
>
>
> HTH,
> David
>
>
> On 7/19/07, *Mike Talbot* <mtalbot at abingdon.oilfield.slb.com 
> <mailto:mtalbot at abingdon.oilfield.slb.com>> 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
>
>     _______________________________________________
>     CMake mailing list
>     CMake at cmake.org <mailto:CMake at cmake.org>
>     http://www.cmake.org/mailman/listinfo/cmake
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070719/1c67795c/attachment.html


More information about the CMake mailing list