[Cmake] CMake using environment variables

Brad King brad.king at kitware.com
Fri Sep 17 07:11:57 EDT 2004


Marco Spatz wrote:
> I'm a newbie to cmake,  and I have to "convert" existing cmakelists.txt 
> useb by cmake 1.8.3 to cmake 2.0.3 format. This ain't to much, but in 
> the old cmakelists.txt we use $(PFROOT) to access a global variable set 
> in windows, but the new cmake complains about that syntax. But what is 
> the correct syntax or way to access that variable? I tried ${PFROOT} 
> already, but that didn't work.

The $(PFROOT) syntax was not actually referencing the variable from 
CMake anyway.  The string was just getting passed through to the 
generated build system.  It is just luck that it was working everywhere 
because both make and Visual Studio know how to evaluate the syntax.  To 
really access the variable from CMake you can use the syntax Jan 
suggested: "$ENV{PFROOT}".  If you want to continue passing the string 
$(PFROOT) through to the generated files then you can just put it in 
double quotes in the CMakeLists.txt code: "$(PFROOT)"

Either way, the fact that $(PFROOT) without quotes in CMake 2.0 does not 
work is unintentional.  It is an accidental side effect of the new 
parser implementation needed to allow multiline strings.  Please submit 
a bug report here:

http://www.cmake.org/Bug

Thanks,
-Brad


More information about the Cmake mailing list