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

Marcel Loose loose at astron.nl
Thu Mar 19 09:50:29 EDT 2009


Hi Eric,

I used "make test" first, but that failed the same way ctest fails.
However, ctest -V at least gave me some more (useful) output.

There's a C++ source file t_hello.cc in the test directory that should
be compiled to produce an executable t_hello. So yes, maybe I'm using
the wrong arguments. It's not really clear to me what I should specify
for --build-project and --test-command. As I said: I must be doing
something wrong, but I don't know what exactly.

BTW, you broke up the output of "ctest -V", which might suggest that you
think I entered several commands, but that's not the case.

Best regards,
Marcel Loose.

On Thu, 2009-03-19 at 13:47 +0100, Eric Noulard wrote:
> 2009/3/19 Marcel Loose <loose at astron.nl>:
> > Hi all,
> >
> > I've been searching for a way to implement "make check" the GNU
> > Autotools way. That is: tests are not compiled and linked as part of the
> > "all" target, but as part of the "check" target.
> >
> > I followed section 10.5 "Using CTest to Drive Complex Tests" of the book
> > "Mastering CMake" and I looked at the Tests directory of the CMake
> > distribution. From that I created my little toy project "Hello".
> >
> > Now the problem is: it doesn't work. For details, see below.
> 
> 
> [...]
> 
> > $ cat test/CMakeLists.txt
> > include_directories(${CMAKE_SOURCE_DIR}/src)
> > add_test(t_hello ${CMAKE_CTEST_COMMAND}
> >  --build-and-test
> >  "${CMAKE_CURRENT_SOURCE_DIR}"
> >  "${CMAKE_BINARY_SOURCE_DIR}"
> >  --build-generator ${CMAKE_GENERATOR}
> >  --build-makeprogram ${CMAKE_MAKE_PROGRAM}
> >  --build-project t_hello
> >  --test-command t_hello)
> 
> Then your test is command is to ... run ctest on the same project?
> This looks like a endless recursion that will call ctest for ever?
> 
> 
> > $ ctest -V
> 
> Step 1: you call ctest...
> 
> > UpdateCTestConfiguration
> > from :/export/home/loose/work/hello/build/DartConfiguration.tcl
> > Parse Config
> > file:/export/home/loose/work/hello/build/DartConfiguration.tcl
> > Start processing tests
> > UpdateCTestConfiguration
> > from :/export/home/loose/work/hello/build/DartConfiguration.tcl
> > Parse Config
> > file:/export/home/loose/work/hello/build/DartConfiguration.tcl
> > Test project /export/home/loose/work/hello/build
> > Constructing a list of tests
> > Done constructing a list of tests
> > Changing directory into /export/home/loose/work/hello/build/test
> >  1/  1 Testing t_hello
> 
> then you test is to .... call ctest ...
> 
> > Test command: /usr/bin/ctest
> > --build-and-test /export/home/loose/work/hello/test  --build-generator
> > Unix\ Makefiles --build-makeprogram /usr/bin/gmake --build-project
> > t_hello --test-command t_hello
> 
> Here you call t_hello which would (if ever it suceed)
> call ctest....
> 
> > Test timeout computed to be: 1500
> > Could not find executable t_hello
> 
> Hopefully there is no t_hello executable its a ctest "test name".
> 
> 
> 



More information about the CMake mailing list