Parallel builds with qmake

So you’d like to run make -j4 on your qmake project (or make -j3, make -j2, hi google). Yes, it is possible, but like many things qmake, it is not documented. As usual, the best way to learn about qmake is to see how Qt itself uses it. Actually, I recommend Qt’s own build files as a primary source for qmake information anyway, as if you know where something ought to be in a project then it is faster to find it than going through the formal manual.

In a SUBDIRS project, you may have something like this:

SUBDIRS += library unittest examples

Change it to this:

# depend on variables, not actual directories
SUBDIRS += sub_library sub_unittest sub_examples

# specify the directories and dependencies
sub_library.subdir = library
sub_unittest.subdir = unittest
sub_unittest.depends = sub_library
sub_examples.subdir = examples
sub_examples.depends = sub_library

Have fun.

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

At least in QT4, when you change the name of the SUBDIRS value, you change the name of the directory that it uses to "cd ___" For example, my Makefile would have said in it "cd sub_library" and "qmake sub_library.pro"

I believe in my version of qmake, 2.01a, the ".subdir" direction didn't work.

My solution, when using your example, was to leave SUBDIRS alone and just call out the depends...

SUBDIRS += library unittest examples

unittest.depends = library
examples.depends = library

Trackbacks

  1. [...] Parallel building makes a massive improvement though, with modern multicore CPUs. If you're running with Qt Creator, you can force your whole project to build in parallel by going to Projects -> Build Settings -> expanding the 'Make:' build step and setting Make arguments to -j3 MAKE="mingw32-make -j3" (where 3 is your number of parallel steps.) YMMV on that, though. You may need to better specify dependencies, as described here. [...]