2012/1/21 Dominik Szczerba <[email protected]>:
>> Running something from the command line does not mean it doesn't change the
>> environment.
>>
>> Would you try
>>
>> $ env > env1.txt
>> $ module unload sysmodule_you_dont_want
>> $ env > env2.txt
>> $ cmake -E compare_files env1.txt env2.txt
>>
>> I'd be surprise if nothing changed but I may be wrong.
>
> You are of course right, but this is not the scenario here. If you put
> "module un/load XXX" into a bash script, and call it from command
> line, it will only modify the env for this script/process. On the
> return your original env will not be changed.

The very same scenario is happening with CMake.

> To change it,  you need
> to "source" your script, but that is what seems to do nothing with
> cmake.

Yes that's precisely the point CMake is not behaving like a shell at ALL
with respect to env var.

Re-read my other message.

When cmake executes a command (using e.g. execute_process)
it "forks" that is a NEW process which is a child of current cmake process
is created, then the command/executable is run within the child
(or replace the child http://en.wikipedia.org/wiki/Fork-exec)
then the child terminates and CMake continue with other
command with may be other child process.

So when you "COMMAND module unload blah" this only
affect the current child.

That's the same difference between "sourcing" a script and "running it"
with CMake you have no way to "source a shell script" because CMake
is not the shell.

>From within CMake you "source" a cmake script (just include it)
but not a shell script (which seems to be the machinery behind the
'module' command).

What you can do however is to identify which environment change did the
module unload do and then do the same with cmake.

You may be able to monitor the change from cmake using a shell script
which does:

env > file1
module unload
env > file2
diff file1 file2

--> then process the diff ouput with some cmake script
en reproduce the environnement change using
set(ENV{EnvVarName} "newValue")
-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
--

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