Thanks to all for the feedback / suggestions. 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.
http://www.itk.org/Wiki/CMake/Examples#Check_if_environment_variable_is_set On Fri, Sep 14, 2012 at 4:43 PM, Bogdan Cristea <[email protected]> wrote: > On Friday 14 September 2012 16:26:10 you wrote: > > On Fri, Sep 14, 2012 at 4:17 PM, Bogdan Cristea <[email protected]> > wrote: > > > On Friday 14 September 2012 16:13:16 Davis Ford wrote: > > >> if("$ENV{FOO_HOME}" MATCHES "") > > >> > > >> message("You must set FOO_HOME") > > >> return() > > >> > > >> endif() > > > > > > Try something like this > > > > > > if(NOT ENV{FOO_HOME}) > > > message("etc") > > > endif() > > > > > > -- > > > Bogdan > > > -- > > > > > > Powered by www.kitware.com > > > > > > Visit other Kitware open-source projects at > > > http://www.kitware.com/opensource/opensource.html > > > > > > Please keep messages on-topic and check the CMake FAQ at: > > > http://www.cmake.org/Wiki/CMake_FAQ > > > > > > Follow this link to subscribe/unsubscribe: > > > http://www.cmake.org/mailman/listinfo/cmake > > > > I would use the double quotes like you had originally, but use > > STREQUAL instead of MATCHES. Or use MATCHES "^$" to match ONLY the > > explicitly empty string, because MATCHES "" basically matches > > everything because everything "contains" the empty string... > > > > HTH, > > David > > I have tested and this should work > > set(VAR $ENV{FOO_VAR}) > if (NOT VAR) > message("Cannot find FOO_VAR") > endif() > > For some reason, when I use directly > if (NOT ENV{FOO_VAR}) > does not seem to work. > > -- > Bogdan Cristea > Software Engineer > tel: +33 (0)6 21 64 15 81 > +33 (0)6 26 74 98 19 > personal site: http://sites.google.com/site/cristeab/ > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- http://daisyworks.com
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
