[CMake] Running tests as part of a build

Gavin Heavyside gavin.heavyside at gmail.com
Fri Jan 8 14:35:58 EST 2010


>
> Have you looked at add_custom_command(TARGET ...) or
> add_custom_target(...)?
> Those are how you run can run commands as part of the build, but after some
> other targets are compiled.
>
> Clint
>

That works great, thanks for the tip!

I build my code, and then my test programs using add_executable.  Then I can
do e.g.:

add_custom_command(TARGET test_harness POST_BUILD COMMAND test_harness)

and test_harness runs after building, with proper dependencies, and a
failing test causes a failing build.  Perfect.  Anything I don't want to run
by default I can leave to add_test on its own.

Thanks very much,

Gavin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100108/42c19794/attachment.htm>


More information about the CMake mailing list