Boost logo

Boost :

Subject: Re: [boost] [cmake] Pull request announcement
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2018-09-20 20:38:38

On 18.09.18 23:04, Peter Dimov via Boost wrote:
> Roger Leigh wrote:
>> CMake already provides two mechanisms for running tests:
>> 1) ctest (the recommended way)
>> 2) "make test" (when using the "Unix Makefiles" generator)
> 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"

I do not remember how the other generators such as Visual handle this. I
remember that, if I build "all targets" in Visual, it tries to
compile/build as much as possible targets that are on independent
subtrees, but my memory is failing right now.

> So the custom "check" target that just invokes `ctest` and depends on
> all test executables is a workaround for the above.
> Now all that's good and well, but what we're interested in here is:
> - how do I write my CMakeLists and what do I type to run my library's
> tests, the equivalent of `b2 test` from libdir

Several possibilities:
1- you have labels and you run ctest by filtering on this
2- you have a naming convention, and you run ctest by filtering on this
3- you go to the build folder of that specific library and run ctest. It
still means that you need a naming convention to go to the right folder

I have already 2/, I am adding 1/ :

I would like to mention that, as a developer, I rather want to do

make boost::libx::build boost::libx::test

instead of "make all test".

I should be able to run all the build targets for a specific library.
boost::libx::test obviously depends on boost::libx::build, and
boost::libx::test is not executed by default.
Also, if I am working on eg. boost.test, I may want to see only the
parents of boost.test in my IDE (and not all of boost). In some specific
cases, I want all libraries. Means that I need to be able to filter from
top, at the time I am generating the cmake project.

The nice thing is that all those things I am mentioning, I have them
already implemented.

Further, one would like to run

make boost::all::build

and also

make boost::libx-descendants::test

(running the tests of all descendants of boost.libx).

I will try to add those last two things, I think those are nice features.

> and
> - how do I write my CMakeLists and a root CMakeLists and what do I type
> to run several libraries' tests at the same time, the equivalent of `b2`
> from the `status` directory

Even better: it is easy to list all the tests that have been declared
inside a directory. I am adding this to my super boost-cmake repo
(previous link).


Boost list run by bdawes at, gregod at, cpdaniel at, john at