[CMake] Setting environment variables

Chris Hillery chillery-cmake at lambda.nu
Tue Sep 14 07:05:26 EDT 2010


You didn't mention what operating system you're using, but on Linux, at
least, the second thing you asked for:

I also tried running the envsetup script alone by using the cmake -P
> command, when the script runs it set the values and outputs it correctly,
> however after the script finishes execution the environment is still
> unchanged. I want to set the environment variables permanently.
>

... is impossible. You cannot run any command in a Unix shell and have it
modify the shell's environment. I believe on Windows this is possible, but
I'm not sure.

As for the first thing, though:

I was trying to setup my environment variables before i start a build , but
> they do not seem to be working at all. I basically have a Ctest script
> called driver.ctest which includes another file called envsetup at the
> beginning.
>
> envsetup contains a list of set(ENV{VAR1} VALUE) and sometimes a few
> execute_process calls which store the output into an environment variable.
> However once the driver.ctest script gets to the building part the build
> fails as the environment variables are not set properly.
>

I just tested this out locally and it worked fine for me. When you say that
you "include another file called envsetup", do you literally mean
INCLUDE("envsetup.cmake") in your driver script? If so, that should work,
and it does work for me here - I modified one of my driver scripts to do
this, and confirmed that the variable was set in the environment for both
the ctest_configure and ctest_build steps.

Can you reduce this to a small example, maybe?

Ceej
aka Chris Hillery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100914/8612c01a/attachment-0001.htm>


More information about the CMake mailing list