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

Matthew Woehlke matthew.woehlke at kitware.com
Thu Jan 24 11:17:05 EST 2013


On 2013-01-23 23:52, Alan W. Irwin wrote:
> Whether ordinary or custom targets can be built in parallel depends on
> the back-end being used.  For the "Unix Makefiles" generator it is
> simple;
>
> make -j8 test_everything

With the Ninja generator it is even easier; 'ninja [<target>]' :-). (You 
can also give -jN, but ninja defaults to parallel, with N = cores + 2. 
Also, I think it may be able to do even better parallelization since it 
is not based on recursive build rules, and knows about the entire build 
graph.)

> On 2013-01-23 19:07-0500 Matthew Woehlke wrote:
>> different generators may or may not have the concept of targets in
>> directories. I think you would need to create a uniquely named
>> targetper directory.
>
> @Matthew: That should not be a concern.  Targets are a global concept
> in CMake so are independent of which subdirectory they are created in.

Right; *global* targets are easy and the default. I had read Wojciech's 
original question as wanting per-directory targets, which I think the 
only sane way to accomplish is with a uniquely named target per 
directory. (What I'm not sure about is what would happen if you tried to 
create a target with the same name per directory. It *might* work with 
make, but definitely won't do what you want/expect, if it works at all, 
with other generators. Ergo, what I was trying to say is that I would 
recommend against doing such a thing.)

-- 
Matthew



More information about the CMake mailing list