[CMake] makefile environment variables

Bill Hoffman bill.hoffman at kitware.com
Tue Oct 21 07:56:27 EDT 2008


Daniel Stonier wrote:
> Is there any means of getting cmake to insert an environment variable
> into the makefiles it generates?
> 
> I know you can do the following:
> 
> SET(ENV{PATH} /opt/eldk/usr/bin/ccache:/opt/eldk/usr/bin:$ENV{PATH})
> SET(ENV{CROSS_COMPILE} ppc_4xxFP-)
> 
> and this is sometimes useful for getting cmake to do things without
> having to externally configure your environment, but it doesn't carry
> on to the makefile. So you still need to rely on an externally
> configured variable. What would be nice is if cmake additionally
> inserted those variables into the makefiles so that when you came to
> build, your environment was prepared.
> 

The problem is CMake is not running at build time.  make is running, or 
visual studio, or Xcode or KDevelop.   CMake only runs at configure 
time, so any environment variables set are lost.

-Bill


More information about the CMake mailing list