[CMake] Building CMake in parallel problem

Michael Wild themiwi at gmail.com
Fri Apr 9 04:36:32 EDT 2010


I don't really see why this should be a problem. If "install" depends on "all", everything should be fine, even in the parallel case (otherwise the dependency-tracking is seriously broken). Even if "all" is the ".DEFAULT" target, make should ignore that because I explicitly specified the target "install". I do see the point if I had used "make -j2 install all", but even then, the dependency should prevent anything bad from happening.


I think the problem here is the following snipped (tabs expanded for posting here):

  # Special rule for the target install
  install: cmake
  install: preinstall
          @echo "Install the project..."
          bin/cmake -P cmake_install.cmake
  .PHONY : install

If I remove the dependency "install: cmake" everything works fine (since "install" depends on "preinstall" which in turn depends on "all" and from there everything is back to normal).

Michael

BTW: I didn't use MAKEFLAGS in the message to make things more explicit.

On 9. Apr, 2010, at 10:08 , Marcel Loose wrote:

> Hi Michael,
> 
> This is a well-known problem with parallel make. When using -j<N> you
> should NEVER specify multiple targets, because each target could be
> built independently in a separate make process even if they have
> dependencies. Here, you're using the implicit target 'all' and the
> target 'install'. The "proper" way to write this in a one-liner would
> be:
> 
> make -j2 && make -j2 install
> 
> You might consider to set MAKEFLAGS=-j2.
> 
> HTH,
> Marcel Loose.
> 
> On Fri, 2010-04-09 at 07:50 +0200, Michael Wild wrote:
>> Hi all
>> 
>> While creating a formula for Homebrew on Mac OS X 10.6.2 I happened
> across a problem when I tried to build CMake 2.8.1 in parallel (-j2) and
> directly invoked the "install" target where libcmsys.a and libCMakeLib.a
> get built twice. I.e. I did the following:
>> 
>> $ <path/to/source>/bootstrap --prefix=<prefix> --system-libs
> --datadir=/share/cmake \
>>  --docdir=/share/doc/cmake --mandir=/share/man
>> 
>> $ make -j2 install
>> 
>> 
>> Looking through the log, I found that both libcmsys.a and
> libCMakeLib.a get built twice, where sometimes the second thread
> interferes with the first, especially during the linking stage. If I
> split the build and install steps, i.e
>> 
>> $ make -j2
>> $ make install
>> 
>> I don't observe this weirdness. Is this a bug in the generated
> Makefiles or in Make?
>> 
>> Michael
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>> 
>> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
> 
> 



More information about the CMake mailing list