Unfortunately, there is no easy way (perhaps no way at all?) to tell the difference between &quot;empty string value of an env var&quot; and &quot;env var does not exist&quot;.<br><br>But you can do this:<br><br>IF(&quot;$ENV{TESTVAR}&quot; STREQUAL &quot;&quot;)
<br>&nbsp; # code to handle empty/non-existent env var<br>ELSE(&quot;$ENV{TESTVAR}&quot; STREQUAL &quot;&quot;)<br>&nbsp; # code that uses non-empty &quot;$ENV{TESTVAR}&quot;<br>ENDIF(&quot;$ENV{TESTVAR}&quot; STREQUAL &quot;&quot;)
<br><br><br>HTH,<br>David<br><br><br><div><span class="gmail_quote">On 11/16/07, <b class="gmail_sendername">Sören Freudiger</b> &lt;<a href="mailto:muffmolch@gmx.de">muffmolch@gmx.de</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Just a short question.<br><br>How to check if an environment variable exist?<br><br>Something like:<br>IF( ENV{TESTVAR} )<br>...<br><br>Because elsewise I get errors at $ENV{TESTVAR} if TESTVAR doesn&#39;t exist...<br><br>
Best,<br>SirAnn<br><br><br><br>_______________________________________________<br>CMake mailing list<br><a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br><a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake
</a><br></blockquote></div><br>