[CMake] cmake + ninja how to use several CPU cores?

Alan W. Irwin Alan.W.Irwin1234 at gmail.com
Mon Jul 29 14:04:56 EDT 2019


On 2019-07-29 18:50+0300 Dave Milter wrote:

> On Mon, Jul 29, 2019 at 1:48 PM Bruce Stephens
> <bruce.r.stephens at gmail.com> wrote:
>>
>> I think it's reasonable for CMake/Ninja to require the headers be
>> generated, especially since main.cpp does include one of them (though
>> CMake/Ninja doesn't know that until later). lib/lib1.cpp is more
>> arguable, but I imagine there's no real distinction made: main.cpp.o
>> depends on all the dependencies of the libraries.
>>
>
> In my initial example headers files are not generated in cmake scripts.
> Only source code are generated, so main.cpp -> main.cpp.o doesn't
> depend on anything.
> But generated by cmake build.ninja still require link of extern_lib
> before starting  main.cpp -> main.cpp.o

Thanks, Bruce, for spotting that issue with the first version of my
simple example which I oversimplified.  I have
now corrected it (see attached tarball) to follow the use case of
pre-existing headers and an app that links to a library (internal for
my corrected test case, and external for David's test case).

The issue (compilation of main.cpp is unreasonably delayed for
parallel builds until after the library (internal or external) is
built) still shows up in my corrected test case for both -G"Ninja" and
-G"Unix Makefiles" just like happens for David's test case for an
external library.

So the question remains why does CMake constrain parallel builds this
way (to the point that it is a bottlneck for David's real project with
external libraries) for this general use case?

Alan
__________________________
Alan W. Irwin

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.org); 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
__________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: corrected_add_internal_library.tar.gz
Type: application/x-gtar-compressed
Size: 1087 bytes
Desc: tarball containing corrected test case of app with pre-existing headers and internal library
URL: <https://cmake.org/pipermail/cmake/attachments/20190729/6268b5c6/attachment.tgz>


More information about the CMake mailing list