Why do Visual Studio Multi-Processor builds do multiple projects instead of multiple source files?

StackOverflow https://stackoverflow.com/questions/23438557

In the NT build environment a.k.a. Windows DDK build environment, you could build your source tree using multiple processors by specifying the -M parameter to build.exe. What it did was build your projects sequentially ordered by dependency, and when it was building each project, it would spin up multiple threads to build the individual source files, obviously, first building the precompiled header, and any other things that needed to be done before the rest of the source could be built (midl, etc.)

Visual Studio/MSBuild takes a very different approach. It build projects using multiple threads, but only builds the individual source files sequentially. This works great when you have a lot of small projects. When you have projects with a lot of source files, this is frustrating, though.

Is anyone in the know enough to know why the Visual Studio people don't use threads for building individual source files like the Windows folk do (or at least used to)?

有帮助吗?

解决方案

The answer to my question is the element. To see it in the GUI, bring up project properties, choose "C++", and then "General". If you set it to true, then that project will first build the PCH file, then it will spin up a "cl.exe" process for each c/cpp file up to the number of processors the machine has. Once all files are built, then it will link with one process.

This is different than the fact that Visual Studio will also spin up multiple copies of msbuild to build multiple projects at once.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top