[CMake] Test if ENV${VAR} is set

Davis Ford davis at daisyworks.com
Fri Sep 14 16:13:16 EDT 2012


Hi, I'm new to CMake -- trying to do something relatively simple.  Not
having much luck -- I've scoured the docs/wiki, but searching the manual
http://cmake.org/cmake/help/v2.8.9/cmake.html in the browser results in a
million hits for a search string.

I just want to test if an environment variable is set and if it is not,
print a message and exit

Something like:

if("$ENV{FOO_HOME}" MATCHES "")
   message("You must set FOO_HOME")
   return()
endif()

This does not seem to work.  I've tried setting and unsetting $FOO_HOME,
and the if condition always applies.

What am I missing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120914/ba2f4648/attachment.htm>


More information about the CMake mailing list