[CMake] Passing environment variables in Windows

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Jan 14 10:32:47 EST 2009


On Wed, Jan 14, 2009 at 3:27 PM, Leo Breebaart <leo at lspace.org> wrote:
> I have created a CMake custom command that I use to invoke a
> pre-existing executable. Unfortunately, this executable also
> needs a custom environment variable in order to function
> correctly. Is there any way to set and pass on this environment
> variable to the executable in CMakeLists.txt, *on Windows*?
>
> On Linux, it is simple: I can just say something like:
>
>   COMMAND FOO_DIR=${CMAKE_SOURCE_DIR}/data /usr/local/bin/foo
>
> and that works perfectly. On Windows, I am at a loss as to how I
> can achieve the same effect, other than creating a .bat wrapper
> file that sets the environment variable outside of CMake -- and
> I'd like to avoid that if at all possible.
>
> Am I overlooking something?

$ cmake --help-command set
...

     <variable> can be an environment variable such as:

         set( ENV{PATH} /home/martink )

       in which case the environment variable will be set.


2cts
-- 
Mathieu


More information about the CMake mailing list