parallel multi-cpu multi-core build
-
Has anyone had success getting QtCreator to build with multiple cores on Windows with Microsoft compilers and cmake project files? My project uses cmake 3.4.0 and MS visual studio 12 2013.
In "Kits" I see that QtCreator is using "CodeBlocks - NMake Makefiles" and nmake does not do parallel compilation.
I know that if I use the Visual Studio 12 2013 generator in cmake (which our Continuous Integration uses) I can add options on the cmake command line (-- "/m:%NUMBER_OF_PROCESSORS%" "/p:BuildInParallel=true") to get a parallel build. However, in QtCreator if I switch to building with "Visual Studio 12 2013 [arch]" generator I get cmake errors and QtCreator cannot parse the project.
Any suggestions on how to set this up would be welcome.
-
@VRonin
Anything else? I have this checked. Builds seem to use about 12% of my Core i7 in QtCreator. Elapsed build time is: 19:43:17. If I run the equivalent build from the command line with:
cmake --build . --config Release -- "/m:%NUMBER_OF_PROCESSORS%" "/p:BuildInParallel=true"
utilization is around 95% with occasional dips to 50% and elapsed time is 4:17.72.Looking at the output of:
jom /?
I see an option for "/j <n>". This makes me think there might be something needed to cause JOM to light all the cores. It is not clear where this option should be set in QtCreator. Under Build Steps it indicates thatcmake.exe --build . --target all
is the way it is building the project. Adding "/j " to Tool Arguments in the Project settings causes cmake to be invoked as:C:\Program Files (x86)\CMake\bin\cmake.exe" --build . --target all -- /j 4
which I wold have expected to work, however this generates the error20:19:43: Starting: "C:\Program Files (x86)\CMake\bin\cmake.exe" --build . --target all -- /j4 NMAKE : fatal error U1065: invalid option 'j' Stop. 20:19:43: The process "C:\Program Files (x86)\CMake\bin\cmake.exe" exited with code 2.
-
OK, after some extended sleuthing, I have determined the following:
- in Tools->Options->Build & Run->General: Check
Use Jom instead of nmake
- in Tools->Options->Build & Run->Kits: Select your "default" kit and change the CMake Generator to be
NMake Makefiles JOM
instead of CodeBlocks - NMake Makefiles. - You may need to edit your environment to set the PATH variable to include
C:\Qt\Tools\QtCreator\bin
(or wherever you installed QtCreator) so that the jom executable is readily available.
Once all that is done, I am getting good utilization during the compilation process.
- in Tools->Options->Build & Run->General: Check
-
Alas, this does not seem to work on a fresh repository check-out. QtCreator cannot read the project file(s) created in this manner. You have to build your project with one of the CodeBlocks generators first so that you can find and edit your source files. When it is time to build you can switch the kit to using the
NMake Makefiles JOM
. What we seem to lack is an ability to use JOM with the CodeBlocks - NMake Makefiles.