views:

891

answers:

3

I am using qmake to generate MinGW32 Makefiles for a small Qt C++ app we are developing. My problem: all those dual/quad core CPUs are sitting there idly while only one thread is doing the building. In order to parallelize things I tried passing --jobs 4 to make, but the problem is that qmake generates a generic makefile inside of which make gets called again with -f .

Is it possible to force qmake to add options to make when generating the makefile? Or maybe there's another way of setting the option outside of qmake altogether? I can't edit that specific Makefile since it's autogenerated each build.

+1  A: 

The generic Makefile uses $(MAKE) when invoking make, so you can overwrite it using environment variables. Something like this should do it:

  qmake
  make MAKE="mingw32-make -j4"

Replace the values of MAKE as required of course :)

bluebrother
+9  A: 

Abusing $MAKE to pass options does not work in all cases. Oftentimes, (e.g. in the configure script of Qt on Unix), it's enclosed in double quotes ("$MAKE") to allow the command to contain spaces. I know because I used the same trick before it stopped working. Qt Support then suggested (rightfully) to use $MAKEFLAGS as in

set MAKEFLAGS=-j4
make
+2  A: 

This works for me:

set MAKE_COMMAND=mingw32-make -j%NUMBER_OF_PROCESSORS%

GED