Thanks to all for the feedback / suggestions.<div><br></div><div>I did edit the wiki -- feel free to revise my submission or extend with your own. I linked to this thread on there, as well.</div><div><br></div><div><a href="http://www.itk.org/Wiki/CMake/Examples#Check_if_environment_variable_is_set">http://www.itk.org/Wiki/CMake/Examples#Check_if_environment_variable_is_set</a><br>
<br><div class="gmail_quote">On Fri, Sep 14, 2012 at 4:43 PM, Bogdan Cristea <span dir="ltr"><<a href="mailto:cristeab@gmail.com" target="_blank">cristeab@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Friday 14 September 2012 16:26:10 you wrote:<br>
> On Fri, Sep 14, 2012 at 4:17 PM, Bogdan Cristea <<a href="mailto:cristeab@gmail.com">cristeab@gmail.com</a>> wrote:<br>
> > On Friday 14 September 2012 16:13:16 Davis Ford wrote:<br>
> >> if("$ENV{FOO_HOME}" MATCHES "")<br>
> >><br>
> >> message("You must set FOO_HOME")<br>
> >> return()<br>
> >><br>
> >> endif()<br>
> ><br>
> > Try something like this<br>
> ><br>
> > if(NOT ENV{FOO_HOME})<br>
> > message("etc")<br>
> > endif()<br>
> ><br>
> > --<br>
> > Bogdan<br>
> > --<br>
> ><br>
> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> ><br>
> > Visit other Kitware open-source projects at<br>
> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> ><br>
> > Please keep messages on-topic and check the CMake FAQ at:<br>
> > <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
> ><br>
> > Follow this link to subscribe/unsubscribe:<br>
> > <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
><br>
> I would use the double quotes like you had originally, but use<br>
> STREQUAL instead of MATCHES. Or use MATCHES "^$" to match ONLY the<br>
> explicitly empty string, because MATCHES "" basically matches<br>
> everything because everything "contains" the empty string...<br>
><br>
> HTH,<br>
> David<br>
<br>
</div></div>I have tested and this should work<br>
<br>
set(VAR $ENV{FOO_VAR})<br>
if (NOT VAR)<br>
message("Cannot find FOO_VAR")<br>
endif()<br>
<br>
For some reason, when I use directly<br>
if (NOT ENV{FOO_VAR})<br>
<div class="im HOEnZb">does not seem to work.<br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Bogdan Cristea<br>
Software Engineer<br>
tel: <a href="tel:%2B33%20%280%296%2021%2064%2015%2081" value="+33621641581">+33 (0)6 21 64 15 81</a><br>
<a href="tel:%2B33%20%280%296%2026%2074%2098%2019" value="+33626749819">+33 (0)6 26 74 98 19</a><br>
personal site: <a href="http://sites.google.com/site/cristeab/" target="_blank">http://sites.google.com/site/cristeab/</a><br>
</font></span><div class="HOEnZb"><div class="h5">--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><a href="http://daisyworks.com" target="_blank">http://daisyworks.com</a></div><br>
</div>