[CMake] Capturing/processing output of the ADD_TEST command

David Cole david.cole at kitware.com
Wed Jul 28 12:15:12 EDT 2010

The easiest way to separate output is to wrap your test in a cmake -P
script, and then inside that call execute_process to run the "real test" and
use its facilities to capture output into variables or redirect output to

There is no redirection of output using add_test arguments.


On Wed, Jul 28, 2010 at 12:01 PM, Emmanuel Blot <eblot.ml at gmail.com> wrote:

> Hi,
> I'd like to run some static analysis tool from CTest. (2.8.1)
> I've added enable_testing() and add_test() calls in my CMakeLists.txt
> file, and the static analysis tool is invoked as expected, however:
>  * CTest discards both the tool standard output and tool standard
> error stream when ran with no option, which makes the purpose of the
> analysis useless;
>  * CTest preserves both tool stream outputs when run with the -V
> option, but add its own output messages to the resulting info, which
> makes the analysis output nearly impossible to read.
> 1/ Is it possible to keep the standard error stream from the tool and
> to discard CTest ouput and the tool's stdout ?
> 2/ It does not seem CTest follows the same convention as CMake's
> ADD_CUSTOM_COMMAND which accepts an 'ARGS' argument and stream
> redirection (using '>'). What's the equivalent syntax in CTest?
> Thanks,
> Manu
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100728/5b2b6e72/attachment.htm>

More information about the CMake mailing list