Thursday, 24 October 2013

Every time you use CONFIG+=ordered, a kitten dies.

QMake users: public service announcement. If you use CONFIG+=ordered, please stop right now. If you don't, I'll hunt you down. I promise to god I will.

There is simply no reason to use this, ever. There's two reasons this might be in your project file:
  1. you have no idea what you are doing, and you copied it from somewhere else
  2. you have a target that needs to be built after another target, and you don't know any better
If you fit into category 1, then I hope you're turning red right now, because by using CONFIG+=ordered, you're effectively screwing over multicore builds of your code. See a very nice case of this here.

If you fit into category 2, then you're doing it wrong. You should specify dependencies between your targets properly like this:

TEMPLATE = subdirs
SUBDIRS = src plugins tests docs
plugins.depends = src
tests.depends = src plugins

And then you'll have docs built whenever the build tool feels like it, and the rest built when their dependencies are built.

If you have subdirectories involved in this, then you need an extra level of indirection in your project, but it's still not rocket science:

TEMPLATE = subdirs
src_lib.subdir = src/lib = sub-src-lib

src_plugins.subdir = src/plugins = sub-plugins
src_plugins.depends = sub-src-lib

SUBDIRS = src_lib src_plugins

For those of you wondering why I sound frustrated about this, I've fixed so many instances of this by now that it's just getting old and tired, frankly. And I still keep running into more. That's countless minutes of wasted build time, all because of laziness boiling down to a single line. Please fix it.


  1. Pick a random qt project from, and you'll probably find "ordered". My first hit was qt-creator. Yup, ordered is there.. Test two, "qt-components", sure.. Before this gets fixed qmake needs documentation..

    1. qmake has documentation. Dependencies are even documented for SUBDIR type projects ( The problem is that nobody reads the documentation and just cargo-cults from what everyone else has done.

    2. Wow cool, I haven't even looked at those for Qt 5.0

    3. It's amazing that programmers who will be fastidious about creating a perfectly elegant system, will then proceed to create the most convoluted build system known to man.

    4. From the linked documentation: "If you need to ensure that the subdirectories are built in the order in which they are specified, update the CONFIG variable to include the ordered option"...

      Nowhere does it say that multicore compilation is bungled. A possible solution is not the same as a recommended solution.

      But forget about that and start putting pressure behind QBS, their next build system. It is specified using QML syntax and tech, and I can vouch for an amazing speedup on windows where qmake suffers notoriously from slow file stat'ing. Agreed, the QtCreator integration still lacks somewhat, but even at this stage I am willing to suffer anything to make Qt development on windows feel even just a tad like python scripting.

      QtCreator menu => Help => About Plugins... Enable QbsProjectManager.

      You'll never go back. Qmake is a dead horse.

  2. I actually use 'ordered' on PPSSPP and can't see any better alternative. I don't fit in to either of those categories. I need to build 4 separate project files.

  3. From the manual page you linked:

    .depends This subproject depends on specified subproject. Available only on platforms that use makefiles.

    That is a pretty good reason to not use this method as not all project files generated by qmake are makefiles.

  4. It should be noted that this doesn't work for the install target. You need explicit CONFIG += ordered, or `make install` will not install subprojects in the correct order and things will break.

  5. Great thanks for this information!