On 2010-02-11 01:20, David Cole wrote:
On Wed, Feb 10, 2010 at 7:16 PM, Alan W. Irwin


    Would setting that environment variable from cmake affect subsequent
    Windows
    builds?  I don't have any Windows development experience, but this
    question
    just came up on the PLplot list. There, we all speculated from our
    various
    Linux and Windows platform perspectives that SET(ENV{PATH} ...) just
    sets
    the PATH when you are running cmake and would have no effect on the
    environment for the subsequent build.  Thus, we thought you would
    have to
    externally set the PATH before running the build.  But we all could
    be wrong
    which is why I have asked this question.  :-)


Alan,

You are correct. Doing this...

SET(ENV{xxx} "value")

...in a CMakeLists.txt file only sets an environment variable for the duration of the cmake run. It has no influence on downstream build steps.


The story with environment variables on Windows is slightly more
complicated than that:
- On Linux/UNIX you can set environment variables for the duration of
  a shell process via the set (setenv) command and by putting such
  commands in a shell script and using . (or source) to run the
  script in the same shell. This does not happen if you run the
  shell script normally (as it is run in a separate process then).

- On Windows (or DOS if you want to include some history) there is
  no separate "source" command. Instead if you set an environment
  variable in a batch file and run that batch file in a DOS-box,
  it will keep that value even after the batch file has finished -
  the batch file is run in the same process (an exit statement in
  such a batch file exits the DOS-box!). If you run a separate
  program, changes to the environment will be lost, just as under
  Linux.

For building PLplot under Windows I extend the path first (so that
includes the directory where the DLLs will be found) and then
run the various commands (CMake and make and the examples). But
that has become an "automatism".

What you could do is wrap the CMake command in a batch file,
including the command "set path=..." and run that instead.

The drawback is that the path will be expanded each time
you run it.

Regards,

Arjen
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to