[CMake] ctest: how to include pre- and post- processing commands
Mario Werner
mario.werner at iaik.tugraz.at
Fri Jul 1 08:30:19 EDT 2016
Hi Ted,
On 2016-06-30 14:37, TS wrote:
> [snip]
> Is it possible to have a ctest which involves preprocessing as well as
> postprocessing. The code to test is myCode.exe, which writes an output file.
> PASS or FAIL is the result of comparison of output against reference data.
AFAIK, there is currently no direct language support for this in
cmake/ctest. However, you can achieve the desired result by using a
custom script which does the preprocessing, the target execution, and
the postprocessing.
I attached you an example for such a "wrapper" cmake script, which I
once used for direct file comparison. I presume that your comparison is
slightly different but it should get you started. The `add_test` looks
then something like that:
```
add_test(NAME test
COMMAND ${CMAKE_COMMAND}
-D "PROGRAM:STRING=$<TARGET_FILE:target>;infile;outfile"
-D "PRE_DELETE_OUTPUT_FILES:BOOL=true"
-D "REFERENCE_FILES:STRING=reffile"
-D "OUTPUT_FILES:STRING=outfile"
-P "${CMAKE_SOURCE_DIR}/path-to-script/run_and_compare.cmake" )
```
> [snip]
> but because rm is not build by cmake, it complains that cannot find it.
>
>
Kind of unrelated to your original question but you can use either
`file(REMOVE ...)` within a cmake script, or call `cmake -E remove ...`
to delete files in a platform independent way.
Regards,
Mario
-------------- next part --------------
A non-text attachment was scrubbed...
Name: run_and_compare.cmake
Type: text/x-cmake
Size: 2487 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160701/b8b39bf7/attachment.bin>
More information about the CMake
mailing list