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

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Jan 23 23:52:10 EST 2013


On 2013-01-23 19:07-0500 Matthew Woehlke wrote:

> On 2013-01-23 18:08, Wojciech Knapik wrote:
>> 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*.

@Wojciech: 
I do exactly what you describe for a number of build systems I am
maintaining, I create a whole system of custom test targets with all
the required file and target dependencies between them (and other
standard targets such as libraries and executables) with the
combination of add_custom_command/add_custom_target/add_dependencies
commands.  I also maintain a hierarchy of target dependencies using
the combination of add_custom_target/add_dependencies so that there is
one overall target (which I happen to call test_everything) which
depends on every other test target.

> I'm not sure if this is possible (or at least feasible)...

@Matthew and Wojciech:

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

gets the job done.  Other generators I have used with parallel-build
capability are "MSYS Makefiles" and "MinGW Makefiles" on Windows
(actually Wine in my case which I use as a convenient and free in both
senses test Windows platform under Linux). I haven't tried the ""NMake
Makefiles JOM" generator yet, but I plan to do so. The jom backend
(unlike nmake) does have parallel build capability (see
http://qt-project.org/wiki/jom project).  The jom application is part
of the ordinary Qt install for Windows (or Wine) so I plan to give the parallel
build capabilities of jom a try in the future.

> different generators may or may not have the concept of targets in directories.  I think 
you would need to create a uniquely named target per 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.
So the test_everything target mentioned above runs test targets that have
been created in different subdirectories without issues.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list