PDA

View Full Version : Multiple build configurations with qmake



DasHannes
5th October 2011, 14:43
Hello,

i'm looking into possible build systems for a rather large project. Since we're using Qt for GUI and some other things, we're considering qmake.

One problem i couldn't yet solve is that we have several build configurations, each of which has certain features enabled or disabled, like this:

debug_basic
release_basic
debug_more_features
release_more_features
debug_all_features
release_all_featuers

The differences in those configurations are mostly preprocessor directives and some libraries that have to be linked, or not.
In the end, we'd like to have qmake generate Visual Studio and XCode projects and, for Linux, Makefiles that have these targets.

From the qmake docs, i could only see that it's possible to create debug and release targets.
Is there a way to extend the list of targets?

Greetings,

DasHannes

wysota
7th October 2011, 21:17
Sure.

debug_basic {
# ...
}

release_basic {
# ...
}

And then call qmake CONFIG+=debug_basic.

DasHannes
10th October 2011, 19:09
With your suggestion, i would have to call qmake to generate a separate vcproj file for each configuration, is that correct?
What i was hoping to achieve is calling qmake once, and then having


on a windows machine one .vcproj with 6 different build configurations
on a mac one xcode project with 6 different build configurations
on a linux box: a Makefile with 6 different targets


Is that possible?

wysota
10th October 2011, 20:07
I have no idea, very unlikely. Even for debug and release you have two separate Makefiles on Windows and Linux. When using Makefiles you could have one (manually written or autogenerated) Makefile contain references to all other makefiles but for other generators, I doubt it.

Kazys
5th April 2012, 00:47
This may be a little late coming, but for completeness I'll share the best answer I was able to come up with.

I've resorted to using the following QMake conditions:

CONFIG(DebugBuild):message(">>>> Debug build")
CONFIG(ReleaseBuild):message(">>>> Release build")


These values are present both within Visual Studio and QtCreator using the Visual Studio compiler tool chain. "Debug" and "Release" with leading capitals may also work.

Unfortunately it looks like these CONFIG values are not present on other platforms (I tried OSX, under QtCreator). For non-Visual Studio platforms you may be able to find something usable by printing the CONFIG variable value, like so:

message("CONFIG: $${CONFIG}")