[CMake] Parallel builds

Bill Hoffman bill.hoffman at kitware.com
Wed Sep 16 14:41:29 EDT 2015


On 9/16/2015 2:06 PM, Greg Marr wrote:
> This part here is inaccurate, at least with the current CMake and
> Visual Studio: "To set the flag you will have to edit the CMake cache
> with the cmake-gui and add it to the CMAKE_CXX_FLAGS and the
> CMAKE_C_FLAGS."
>
> This is all we do in the CMake file that we include in all our
> projects: add_compile_options(/MP$ENV{NUMBER_OF_PROCESSORS})
>
> If you don't have a NUMBER_OF_PROCESSORS environment variable, you
> just get /MP.
>
> The oversubscription part is still true, but I've never seen randomly
> bad object files.

I was writing it from the point of view of NOT having to edit the 
project.  Seems like more of a per build decision to me.  As there could 
be issues, the most reliable way to build is to not use /MP which is why 
CMake does not just do this by default.  So, I would not want to 
recommend that projects make it a default.  But, you can change the 
flags either by editing the CMakeLists.txt files or by editing the 
CMakeCache.txt file to change the flags in the build.

-Bill



More information about the CMake mailing list