Unfortunately, there is no easy way (perhaps no way at all?) to tell the
difference between "empty string value of an env var" and "env var does not
exist".

But you can do this:

IF("$ENV{TESTVAR}" STREQUAL "")
  # code to handle empty/non-existent env var
ELSE("$ENV{TESTVAR}" STREQUAL "")
  # code that uses non-empty "$ENV{TESTVAR}"
ENDIF("$ENV{TESTVAR}" STREQUAL "")


HTH,
David


On 11/16/07, Sören Freudiger <[EMAIL PROTECTED]> wrote:
>
> Just a short question.
>
> How to check if an environment variable exist?
>
> Something like:
> IF( ENV{TESTVAR} )
> ...
>
> Because elsewise I get errors at $ENV{TESTVAR} if TESTVAR doesn't exist...
>
> Best,
> SirAnn
>
>
>
> _______________________________________________
> CMake mailing list
> [email protected]
> http://www.cmake.org/mailman/listinfo/cmake
>
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to