[CMake] How to build projects with make -j2 and ADD_SUBDIRECTORY?

Michael Wild themiwi at gmail.com
Mon Feb 16 03:42:40 EST 2009


On 16. Feb, 2009, at 8:49, Micha Renner wrote:

> How to build projects with make -j2 and ADD_SUBDIRECTORY?
>
>
> A TOP-Level CMakeLists.txt has the following lines:
>
> ADD_SUBDIRECTORY(libtiff) # The Library
> ADD_SUBDIRECTORY(test)	  # Programm depending on libtiff
> # more subdiretories depending on libtiff
>
> The build-command is:
> 	make -j2
>
> The result is: make cancels the build of the test-subdirectory  
> (libtiff
> isn't ready).
> What can I do that the project in the test-directory waits until the
> build of the libaray is done?
>
> I guess, this is something what CMake can't do yet.
>
> With best regards
> Michael
>
>

Hi Michael

This works for me (Mac OS X 10.5.6, GNU Make 3.81). What version of  
Make are you using? Reasonably recent versions of GNU Make should be  
able to do exactly that, but AFAIK, nmake and MSYS Make have serious  
trouble getting parallel builds right (or do not have the feature at  
all).

Whether parallel builds are available is not so much a thing that  
CMake handles, but the native build system (in your case some variant  
of Make).


Michael


More information about the CMake mailing list