How do I utilise all the cores for nmake?

C++EclipseQtMulticoreNmake

C++ Problem Overview


I just got a new quad core computer and noticed that nmake is only using 1 process.

I used to use make which had the switch -j4 for launching 4 processes. What is the nmake equivalent?

[edit] Based on the information below I have been able to add a command to my qmake project file:

QMAKE_CXXFLAGS += /MP

Which effectively did it for me. Many thanks.

C++ Solutions


Solution 1 - C++

Another generic, non-Qt-related way to tell nmake to use all the cores is to set environmental variable CL to /MP:

set CL=/MP
nmake

will use all the CPU cores.

Solution 2 - C++

QT has a tool for this: http://download.qt.io/official_releases/jom/

They also use it per default in Qt creator.

Solution 3 - C++

According to MSDN, there's no such option for nmake.

You can however make the compiler build multiple files in parallel by using the /MP option with the VC++ command line compiler and passing multiple files at the same time:

> cl /MP a.cpp b.cpp c.cpp

However note that most Makefiles don't call the compiler like this - they usual invoke the compiler separate for each individual source file, which would prevent the /MP option from doing anything useful.

Solution 4 - C++

Incredibuild claims to be able to run nmake builds on multiple cores / multiple machines. I don't have any experience of it.

Solution 5 - C++

The CMake 2.8.1 RC1, as for the time of writing this it's ready to try, does bring new generator for NMake which is called NMake Makefiles JOM and it generates NMake with specific settings for jom, which is the drop in replacement of NMake. Thus, it gives multi-processing enabled building using NMake.

Solution 6 - C++

Solution 7 - C++

This doesn't work for normal makefiles, but there is a setting in Visual Studio 2005 that lets you build more than one .vcproj file at the same time (provided one isn't dependent on the other). Tools -> Options -> Projects and Solutions -> Build and Run -> X maximum number of parallel project builds.

Solution 8 - C++

It's not quite the same, but if you use cmake, you can export solution (e.g. using generator "Visual Studio 14 2015" instead of "NMake Makefiles").

In this case it's possible to build exported solution using msbuild tool which allows you to parallelize building process with /maxcpucount command line switch.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPhil HannentView Question on Stackoverflow
Solution 1 - C++Violet GiraffeView Answer on Stackoverflow
Solution 2 - C++Tolik OdukhaView Answer on Stackoverflow
Solution 3 - C++AlnitakView Answer on Stackoverflow
Solution 4 - C++Martin BeckettView Answer on Stackoverflow
Solution 5 - C++mloskotView Answer on Stackoverflow
Solution 6 - C++Marcin GilView Answer on Stackoverflow
Solution 7 - C++teeks99View Answer on Stackoverflow
Solution 8 - C++Andrey StarodubtsevView Answer on Stackoverflow