[CMake] Trouble with parallel builds for targets created by add_executable, target_link_libraries, and add_library
Alexander Neundorf
a.neundorf-work at gmx.net
Wed Sep 30 15:16:10 EDT 2009
On Wednesday 30 September 2009, Marcel Loose wrote:
> On Tue, 2009-09-29 at 19:46 -0400, Bill Hoffman wrote:
> > Alan W. Irwin wrote:
> > > On 2009-09-29 16:36-0400 Bill Hoffman wrote:
> > >> make -j N is only supported with the all target.
> > >
> > > How difficult would it be to implement parallel build support for more
> > > than just the "all" target? Note, if there is some limitation that
> > > makes it impractical or inefficient to implement this current "all"
> > > target capability
> > > for every target, you could instead implement this capability just for
> > > the targets where this capability is wanted (as designated, say, by a
> > > PARALLEL_BUILD=ON target property).
> >
> > It is very hard to implement on top of make. Let me restate what I
> > mean, it is not the all target that is special. You can do make -j N
> > target. You just can't do make -jN target1 target2 if target1 and
> > target2 have a common target that they depend on. You can only specify
> > one target at a time for make -j N. The /fast targets could be used to
> > avoid the issue you are having maybe...
>
> Hi Alan,
>
> I don't think this is a limitation of CMake. It's rather a limitation of
> make. An (in)famous example of doing a parallel build with 'make' that
> will likely cause a broken build is:
>
> $ make -j4 all install
>
> In this example, it's possible that 'make' will try to install, e.g., a
> library that has yet to be built. The only safe way to run a parallel
> 'make' with multiple targets is to serialize them (sounds contradictory,
> doesn't it?):
>
> $ make -j4 all && make -j4 install
>
> Or better:
>
> $ export MAKEFLAGS=-j4
> $ make all && make install
I never had a problem with "make -j4 install" (which builds "all" first)
Alex
More information about the CMake
mailing list