[CMake] How to emulate autotools "make check"?

Marcel Loose loose at astron.nl
Fri Mar 20 06:29:19 EDT 2009


Hi Erk,

And now, of course, there's the catch. Things work great for my toy
project with only one test program. But my real project has more than
one test program. How should I now create the custom target 'check'? Do
I need to keep a list of all test programs? That would be quite
cumbersome, because my code tree looks something like this.

project-root
  dir1
    src
    test
  dir2
    dir3
      src
      test
    dir4
      src
      test

Calling 'make check' should then compile, link and run the test programs
in all the different test directories.

Best regards,
Marcel Loose.


On Fri, 2009-03-20 at 10:34 +0100, Marcel Loose wrote:
> Hi Erk,
> 
> Thanks for your prompt reply. Your example works great.
> In the mean time, I found another way to solve my problem:
> 
> add_custom_target(check DEPENDS t_hello)
> add_custom_command(TARGET t_hello POST_BUILD
>   COMMAND ${CMAKE_CTEST_COMMAND} t_hello)
> 
> But I think I prefer your solution; it saves an extra
> add_custom_target() statement.
> 




More information about the CMake mailing list