[CMake] Environment variable querying problem

Brad King brad.king at kitware.com
Thu May 26 13:09:50 EDT 2005


alaterale at elitemail.org wrote:
> if you run that before you run something like "export S5300=TRUE" it
> should print out the lower message because it's not defined, right?
> Then after you run that export (or setenv or whatever) the first message
> should print and not the other one, since it is defined.  However, this
> is not what happens for some reason.  Any idea on what could be causing
> this?  Is this something specific to ENV{}?  I'm trying to get the hang
> of this IF statement in terms of environment variables (as those are
> easier for us to set) if you can't tell :P  Any help would be greatly
> appreciated :)

Yes, it is specific to ENV.  Currently there is no way to tell apart an 
empty variable from one that is not set.  The IF command was never 
designed to be used with environment variables.  It is not really safe 
anyway because there are alot of cases where CMake runs behind the 
scenes and might not be in the same environment in which it was first 
run.  If you want to control build settings on the CMake command line, 
you need to use cache variables set with the -D option.  The settings 
will be saved in CMakeCache.txt so that they don't have to be repeated 
every time CMake is run on the same build tree.

-Brad


More information about the CMake mailing list