[cmake-developers] Setting up environment using ExternalProject_Add

Brad King brad.king at kitware.com
Tue Aug 11 09:34:37 EDT 2015


On 08/11/2015 12:49 AM, James Johnston wrote:
>         CONFIGURE_ENVIRONMENT_COMMAND <path to VCVarsAll.bat>
[snip]
>     add_custom_command(<snip> ENVIRONMENT_COMMAND <path to vcvarsall.bat>
>         COMMAND ${CMAKE_PROGRAM} -GNinja <snip>)

A problem with both of these approaches is that on UNIX and in Make
the environment does not persist after the command exits.  Whatever
wrapper tool is used must set the environment and also launch the
real command to be run under that environment.  This is what the
"env" tool (and recently "cmake -E env") does.  Of course on Windows
we need to run the .bat file to set the environment because we do
not know what variables it will set.

So, in order to do something like this we first need to identify a
proper abstraction to capture both cases.

Thanks,
-Brad



More information about the cmake-developers mailing list