[CMake] How to executing a script right after an add_test command ?

Delphinus Delphinus tibouroxane at yahoo.fr
Thu Sep 8 09:30:43 EDT 2011

Hi all,

I am using the Qt module QTestLib to do some tests on my application
(windows, MSVC 2008) that has been all set up with CMake.

A test I have created with QTestLib is executed, all output is sent to the
command window. Since I want it to a file, I used what Qt suggest to
redirect all output: -xml -o my_file.xml
so I do this in my CMake file:

add_test ( NAME   ${PROJECT_NAME}   COMMAND   ${PROJECT_NAME} -xml -o
log/foo.xml )

So now, when I do the "run_test" through visual, my test is run and my file
is created (so far so good!).

My problem is that I want the name of the file to be time and date dependant
(log20110908140230.xml - a year, month, day, hour, minute and second

So I have considered the following solution (I did not succeed in
implementing it so far):
I want to execute a script, just after the execution of my test that will
rename the result file generated.
--> Here I don't know how I can tell CMake to execute my script just when
the test has been executed ?

NB: I do NOT have any problem creating a script that rename a foo.xml file
to a log20110908140230.xml file (my script.bat file is already ready). The
problem is how to make this script to be executed just after the test

Any insight is welcomed on how to implement my suggestion (or if you have
another choice, I'm all ears :)! ).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110908/681f3913/attachment.htm>

More information about the CMake mailing list