[CMake] Parallel builds

Raymond Wan rwan.work at gmail.com
Wed Sep 16 12:03:41 EDT 2015


On Wed, Sep 16, 2015 at 11:44 PM, Petr Bena <benapetr at gmail.com> wrote:
> I would prefer a way to get cmake to generate solution files for MSVC
> in a way that these options are enabled by default. Right now I need
> to do this by hand and when I run cmake again, it overwrites the
> solution files I modified and restore back the settings that disallow
> the multithreaded builds. Basically I would like to know if there is
> some option I would add to CMakeLists.txt that would make it do so. I
> understand that this may not possible with current version of CMake
> though.


I sort of don't see this as being CMake's problem.  Suppose your
computer has 4 cores.  Do you mean you would like CMake to detect that
there are 4 cores and to change the Makefile automatically?  Someone
showed this with two Makefiles [1] -- it's an interesting solution if
you want to try to make the same pair of Makefiles with CMake.  (I
have no idea how, but I guess it's possible?)

I don't know what is the Windows equivalent, but on Linux, I've
aliased "make" to "make -j 4".  So, what you describe about "solution
files" generated by CMake that get overwritten isn't really an issue.

Or maybe I've completely misunderstood you?  Do you want CMake to
detect the number of threads and then to pass that to (a) the program
that would be generated [i.e., for its execution] or (b) the
compilation of such a program?  I've assumed you meant (b)...

Ray

[1]  http://stackoverflow.com/questions/2527496/how-can-i-write-a-makefile-to-auto-detect-and-parallelize-the-build-with-gnu-mak


More information about the CMake mailing list