If you create a VC project file with qmake from qt * .pro, it generates it in such a way that mocables are compiled in a single thread. The only way I know to get around this behavior is to explicitly call jom to preprocess the moc.
I only have VS2012 (win32-msvc2012), but I used a similar thing for VS2010 (win32-msvc2010 in your case)
To do this, you need to automate the following steps:
Create a VC project from the pro file via qmake:
qmake -spec win32-msvc2012 -tp vc -o ${path-to-target}/${your-project}.vcxproj ${path-to-source}/${your-qt-pro}.pro
Create a make file from the pro file via qmake:
qmake -spec win32-msvc2012 CONFIG+=release -o ${path-to-target}/Makefile', ${path-to-source}/${your-qt-pro}.pro
Create the following .bat file next to the vcproj file (put% VS100COMNTOOLS% for vc2010 and x86 / x64 for the arch):
call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" ${arch} md build\release\generated ${environment.dir}\bin\jom.exe -j 16 /F Makefile.release mocables
To debug, change 'release' to 'debug' (or enter a variable)
Now you need to edit the VC project file. Here is what you need to find / replace (using regular expressions):
1) For all includes (tags Project-> ItemGroup-> CustomBuild Include, containing * .h files:
- find:
</CustomBuild> - replace with:
<ExcludedFromBuild>true</ExcludedFromBuild> </CustomBuild>
2) for Project-> ItemDefinitionGroup:
- find:
</Link> - replace with:
</Link> <PreBuildEvent> <Command>build_moc.bat</Command> </PreBuildEvent>
3) for Project-> ItemDefinitionGroup: - find: <ItemDefinitionGroup> - replace with: <Target Name="BeforeClean"> <Message Text="Cleaning moc generated files"/> <Exec Command="del \$\(ProjectDir\)..\\\$(Platform\)\\build\\${arch}\\generated\\moc_*.* /F /Q" /> </Target> <ItemDefinitionGroup>
I am automating it with Maven, so here is the code snippet for the link:
build_moc.bat:
cd %1 md build\%2\generated c:\\develop\\buildenv\bin\jom.exe -j 16 /F Makefile.%2 mocables
maven script that performs replacements (maven-replacer-plugin configuration):
<replacement> <xpath>//Project/ItemGroup/CustomBuild[contains(@Include,'.h')]</xpath> <token><![CDATA[</CustomBuild>]]></token> <value><![CDATA[ <ExcludedFromBuild>true</ExcludedFromBuild> </CustomBuild> ]]></value> </replacement> <replacement> <xpath>//Project/ItemDefinitionGroup[not(@*)]</xpath> <token><![CDATA[</Link>]]></token> <value><![CDATA[ </Link> <PreBuildEvent> <Command>\$\(ProjectDir\)../${arch}/build_moc.bat \$\(ProjectDir\)../${arch} \$\(Configuration\)</Command> </PreBuildEvent> ]]></value> </replacement> <replacement> <token><![CDATA[<ItemDefinitionGroup>]]></token> <value><![CDATA[ <Target Name="BeforeClean"> <Message Text="Cleaning moc generated files"/> <Exec Command="del \$\(ProjectDir\)..\\\$\(Platform\)\\build\\${arch}\\generated\\moc_*.* /F /Q" /> </Target> <ItemDefinitionGroup> ]]></value> </replacement>
I hope this helps