Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Always use multiple cores (/MP) flag with Visual Studio?

I'm using Visual Studio 2008 on my main build system. I've been playing with Visual Studio 2010 on another one. It appears that the tool still only wants to use one core when compiling unless you specify the /MP switch in the compiler switches (see How do I turn on multi-CPU/Core C++ compiles in the Visual Studio IDE (2008)?). I have to do this for every project. Is there a way to make VS always do this?

like image 581
dwj Avatar asked Apr 23 '10 00:04

dwj


People also ask

Does Visual Studio use multiple cores?

As you wished, VS IDE does support multi-core build process.

What is multi processor compilation?

The /MP option can reduce the total time to compile the source files on the command line. The /MP option causes the compiler to create one or more copies of itself, each in a separate process. Then these instances simultaneously compile the source files.


2 Answers

Create environment variable "CL" and set it to "/MP". Microsofts compiler cl.exe always prepend command line flags with this variable.

Some compiler features and options like #import aren't compatible with /MP flag. You will need to add /MP1 to projects used #import in a code. This will disable /MP for those projects.

like image 110
ZAB Avatar answered Sep 19 '22 14:09

ZAB


Your can create a property sheet that all of your projects include, and set the /MP flag in that property sheet.

In Visual Studio 2010, you could put it in the Microsoft.Cpp.Win32.user property sheet, which is included in new projects by default (it has the old Visual C++ directories and other default settings defined in it). I don't know that modifying the default property sheet is really a good idea, but it's certainly an option.

like image 28
James McNellis Avatar answered Sep 21 '22 14:09

James McNellis