[CMake] Building all tests in parallel (whole subtrees)

Eric Noulard eric.noulard at gmail.com
Thu Jan 24 02:51:28 EST 2013


2013/1/24 Wojciech Knapik <wmknapik at gmail.com>:
> Hello everyone
>
> I'm just about done switching a project from plain makefiles to CMake
> and so far it's been great.
>
> As one of the last steps, I wanted to add support for building/running
> unit tests. I set up targets that build the unit test executables and
> marked them with EXCLUDE_FROM_ALL, because I don't want to tie building
> them to building the application code. Now I need a way to build and run
> these tests en masse, since there are too many to do it one at a time.
>
> Ideally I'd like to have a make target, that I could call to build all
> unit tests in the current directory and below *in*parallel*.

If you use makefiel generator then calling it with "-j " parallel
option should do the
parallel building.

Now if you are speaking of "running" the tests in parallel than it looks like
even if ctest has the very same "-j" parallel option for running test
in parallel
the generated "make test" target does not forward the "-j " option given to make
to the ctest call.

i..e for me:

ctest -j 3
  runs 3 tests in parallel (when possible)

whereas

make -j 3 test
  does not.

> All the ways I found to achieve that, essentially boil down to calling
> make with multiple targets and that breaks parallel builds, due to race
> conditions - multiple instances of make writing to the same files.
>
> Is there a way to build multiple tests in parallel ?


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list