Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass /MP option to the compiler using MSBuild

I have a VC project file that I'm building from command line using MSBuild. I want to specify the /MP flag without editing the project file. Is that possible? I've tried set CL=/MP prior to calling MSBuild, but it has no effect.

like image 808
Violet Giraffe Avatar asked Jul 08 '15 13:07

Violet Giraffe


1 Answers

This can be accomplished by accessing the CL_MPCount Visual Studio option:

MSBuild /m:2 /p:CL_MPCount=2 /p:Configuration=Release tf_tutorials_example_trainer.vcxproj

The above instructs the compiler to perform a maximum of 2 parallel compilation tasks. The /m:2 flag allows MSBuild to build two projects in parallel. The net result is that we have a maximum of 4 cl.exe processes running in parallel.

UPDATE: The CL_MPCount=2 flag gets passed on to cl.exe as /MP2. This allows parallel compilation of 2 .cpp files within the same project.

like image 103
KalenGi Avatar answered Sep 30 '22 04:09

KalenGi