C.J.
C.J.

Reputation: 16091

How to make MSBuild use more threads when compiling multiple files?

I have an MSBuild file that I use to compile over 700 header files in a directory. It works perfectly except that it takes so long... I would like it to compile these files faster using multiple processes if possible. Anyone have any ideas on how to do that, using this XML as a start?

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
        xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >

<PropertyGroup>
    ...
</PropertyGroup>

<ItemGroup>
    <SDKFiles   Include="$(CompileDir)\**\*.h" 
            Exclude="$(CompileDir)\**\...;
                    ...
</ItemGroup>

<UsingTask TaskName="CL" AssemblyFile="$(VCTargetsPath)\Platforms\x64\Microsoft.Build.CPPTasks.x64.dll"   Condition="'$(Platform)'=='x64'" />
<UsingTask TaskName="CL" AssemblyFile="$(VCTargetsPath)\Platforms\Win32\Microsoft.Build.CPPTasks.Win32.dll" Condition="'$(Platform)'=='Win32'" />

<Target Name="CompileStuff">
...
    <!-- This CL.exe compiles all the files -->
    <CL Sources="@(SDKFiles)" CompileAs="CompileAsCpp" SuppressStartupBanner="true" ObjectFileName="$(IntDir)" WarningLevel="$(Warnings)" ExceptionHandling="Sync" />
    ...
</Target>
</Project>

I have tried the following, but with no success: 1. Passing in /m to MSBuild on the command line. 2. I tried some XML setting that specified multi-process's but it didn't work either.

Thanks

Upvotes: 2

Views: 860

Answers (1)

C.J.
C.J.

Reputation: 16091

Well since no one helped over these last 5 months, I may as well say that I had to write my own task extension. That task uses multiple threads to compile the files passed in.

Upvotes: 1

Related Questions