[CMake] set environment variable scope
Bill Hoffman
bill.hoffman at kitware.com
Fri Mar 28 19:34:33 EDT 2008
Kaleb Pederson wrote:
> What's the best way to set an environment variable that will be active for a
> custom target or command?
>
> For example:
>
> SET(ENV{TESTING} "MyValueHere")
> MESSAGE(STATUS "Set value to: $ENV{TESTING}")
> ADD_CUSTOM_TARGET(
> target
> COMMAND cmdThatRequiresTestingEnvVar
> VERBATIM
> )
>
> Thanks for the help.
>
There is currently not a direct way to do this. You would have to
create a cmake -P script and call the set(ENV in there. The issue is
cmake time vs build time. When that custom command gets run, the cmake
process is long gone.
-Bill
More information about the CMake
mailing list