[CMake] How to run tests in parallel?

S Roderick kiwi.net at mac.com
Wed Jun 15 07:59:21 EDT 2011


On Jun 15, 2011, at 07:55 , Dave Ohlsson wrote:

> Hi,
> 
> I am new to CMake.
> 
> I have a project with a few tests. The tests are independent from each
> other (run in separate directories, etc.).
> 
> In my project's CMakeLists.txt, I have:
> 
>    enable_testing()
>    add_test(NAME test1 COMMAND <some command 1>)
>    add_test(NAME test2 COMMAND <some command 2>)
>    add_test(NAME test3 COMMAND <some command 3>)
> 
> I can run the tests with this command (from the build directory):
> 
>    make test
> 
> This command runs all the tests SERIALLY, and they all pass.
> 
> Now, how could I run the tests IN PARALLEL?
> 
> I tried this:
> 
>    make -j4 test
> 
> and that:
> 
>    make -j 4 test
> 
> but the tests are run serially also with these commands.
> 
> Note that `make -j 4' builds the objects (.o files) in parallel
> without problems. I have this problem only with tests.
> 
> I suppose I am missing something very obvious.
> 
> I use Linux.

Undocumented feature (IIRC) ...

make -jN test				# build in parallel
make test ARGS=-jN		# run tests in parallel

for appropriate N


More information about the CMake mailing list