[CMake] /MP flag an VS parallel builds
John Drescher
drescherjm at gmail.com
Fri Apr 10 15:32:17 EDT 2009
On Fri, Apr 10, 2009 at 3:25 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Jeff Baumes at Kitware recently made this discovery:
>
>
> Some may already know this, but I found a flag that you can use in
> Visual Studio that enables file-level build parallelism within
> projects like gmake. By default, Visual Studio only allows project-level
> parallelism, which does not always use all your cores, for example if
> you are building a project with a relatively small number of large
> libraries (like VTK) with deeper dependency trees.
>
> To enable this, add the flag /MP to CMAKE_CXX_FLAGS. I (and others)
> noticed significant build time speedup for builds of CMake, ParaView,
> and VTK. This is available in Visual Studio 2008, although some online
> thread discussions state that this flag is also available as a "hidden
> feature" of Visual Studio 2005. But you should probably assume it is
> buggy or incomplete in that version.
>
> The only known possible caveat is that having both file and project
> parallelism on work independently, so having 8 cores with /MP on a
> project with lots of project parallelism could spawn as many as 64
> build threads, which will be inefficient. A repository like VXL with
> 600 projects may fall into this category. You can also play with a
> global setting for all projects (in Options, Projects and Solutions,
> Build and Run) to limit the number of projects built at once if this
> is an issue, or in those cases you can just not use /MP.
>
> Jeff
>
>
> BTW, this seems to beat gmake -j N on my dual core laptop. CMake build went
> from 3m (gmake) to 2m30s VS IDE from the command line.
>
I have had that in my CMakeLists.txt for my main application for a few
months and I use this for the most part with VS2005. I got this info
here:
http://vagus.wordpress.com/2008/02/15/source-level-parallel-build-in-visual-studio-2005/
BTW, I have not noticed any problems related to this flag with VS2005.
John
More information about the CMake
mailing list