[CMake] Passing environment variables in Windows

Leo Breebaart leo at lspace.org
Wed Jan 14 09:27:46 EST 2009


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?

-- 
Leo Breebaart  <leo at lspace.org>



More information about the CMake mailing list