Subject: Re: [boost] [cmake] Pull request announcement
From: Peter Dimov (lists_at_[hidden])
Date: 2018-09-20 21:51:27


Raffi Enficiaud wrote:
> On 18.09.18 23:04, Peter Dimov via Boost wrote:
> > As far as I understand, the problem with `make test` is that it doesn't
> > build the tests. To build them, one does `make all test`, which (a)
> > requires tests to be built as part of the "all" target - which we don't
> > want - and (b) doesn't work with -jN. And `make all && ctest` has the
> > problem of test executable build errors not being part of the ctest
> > output.
>
> The way I understand it is that this is a make behaviour and not a cmake
> one: as soon as an error is detected, the goal cannot be reached and make
> stops. You change this behaviour by passing "-k" / "--keep-going"

Turns out that the "portable" cmake way to achieve the above is to make
building the test executable a test. See

https://github.com/pdimov/mincmake/blob/master/test/CMakeLists.txt
https://github.com/pdimov/mincmake/blob/master/cmake/boost_test.cmake

(and https://github.com/boostorg/assert/blob/develop/test/CMakeLists.txt)

for an example implementation of the Boost test types. With this in place,
"cmake --build . --target check" builds and runs the tests as expected:

https://travis-ci.org/pdimov/mincmake/builds/431060394

This still won't support parallel testing properly if some of the libraries
require building, which is probably fixable by also making building the
library a test on which the rest depend, but I'm not investing any effort
into this specific issue at the moment. Serial testing was good enough for
going to the moon.