[CMake] execute a script before and after configuration

Eric Noulard eric.noulard at gmail.com
Sat Jan 21 03:30:56 EST 2012


2012/1/21 David Cole <david.cole at kitware.com>:
>
>
> On Friday, January 20, 2012, Michael Hertling <mhertling at online.de> wrote:
>> On 01/20/2012 01:57 PM, Dominik Szczerba wrote:
>>> Hi,
>>>
>>> I am building a big software framework on a cray system whereby during
>>> cmake "configuration" phase I need to unload certain system modules
>>> (so that some small test programs are allowed to run without
>>> scheduler) and afterwards, before the actual build phase starts, I
>>> need to load them back. Doing it manually is troublesome, because
>>> sometimes typing "make" triggers cmake to re-run, and then re-build,
>>> so there is no chance to load/unload the modules.
>>>
>>> So, how would I force one script to run when cmake is started and one
>>> other script before build starts?
>>>
>>> Many thanks for any directions.
>>>
>>> Dominik
>>
>> You might use an EXECUTE_PROCESS() command at the beginning of your
>> CMakeLists.txt to unload the modules, and another EXECUTE_PROCESS()
>> at the end to reload them.
>>
>> Regards,
>>
>> Michael
>> --
>>
>> 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
>>
>
> Doesn't the module switching involve setting environment variables? You're
> going to have to do that before invoking CMake aren't you?

As far as I remember (not used cray modules for ages) yes,
there are env var modification.

There is (at least) one similar tool not dedicated to Cray machine,
which works the same way.
http://modules.sourceforge.net/

Usually the main goal is to be able to install several
version of softwares on the very same machine which is shared
by many users and then offer each user a way to "select"
the version of each installed tool.

May be Dominik can explain this
"so that some small test programs are allowed to run without
scheduler"
a little more?

Does it mean you have to unload some module in order
to run without using PBS
(http://en.wikipedia.org/wiki/Portable_Batch_System)
or something similar?

Does this impact try_run or can't you use something like
execute_process(module unload whatever
                          testme this
                          ....)

normally inside the exexcute_process you don't need
module load again because the executed process has been forked.

This should be verified though.



-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list