[Interest] qmake Conditions and Scopes

Lincoln Ramsay lincoln.ramsay at nokia.com
Mon Mar 12 06:13:05 CET 2012


On 03/12/2012 02:33 PM, ext Szalata, Zenon M. wrote:
> I took this from qmake Advanced Usage available in assistant.

It's terribly limiting to make decisions based on the mkspec and almost 
always wrong (even when Qt does it). We've turned up bugs by failing to 
name custom mkspecs in precisely the way Qt's build system assumes 
they're named.

> That fragment does not work. In fact only the first call to message prints
> which seems to mean that the variable QMAKESPEC has null value and the
> two conditions are not met.

Or it's something else that is perfectly valid but doesn't match either 
of those two (like say, linux-g++).

> How can I implement such conditional building based on the host
> architecture?

Test for it. Properly.

If you want to know what the toolchain will produce, ask it (ie. compile 
something that can tell you if it's 32 or 64 bits when run or maybe 
examine the binary if you can't run the binaries produced by the toolchain).

If you want to know what architecture your host machine is, ask it 
(perhaps with uname -a).

Then use your results to write a file qmake can read.

eg.
echo bits=$bits >config.pri

foo.pro:
include(config.pri)
equals(bits,32) {
     # 32-bit
} else:equals(bits,64) {
     # 64-bit
} else {
     # error
}


-- 
Lincoln Ramsay - Senior Software Engineer
Qt Development Frameworks, Nokia - http://qt.nokia.com/



More information about the Interest mailing list