1

I have seen where people will define variables like VERSION using a config.h header with autotools that are constants in C or C++, so that their version numbers are accurate. Is there a way to do this in qmake?

I added a line like

VERSION = 6.3.a

to my project.pro file.

3 Answers 3

2

I think the cleanest way is to define it at compile time like this:

QMAKE_CXXFLAGS += -DVERSION=$$VERSION

You will then be able to access VERSION from any .cpp file.

1

@AlexHenrie's answer is correct but qmake prefers this settings in the DEFINES variable, like this:

DEFINES += VERSION=$$VERSION

For more information, see http://doc.qt.digia.com/4.6/qmake-variable-reference.html#defines

1

Alternatively, you can make qmake generate a config.h file like this:

system(echo \\$${LITERAL_HASH}define VERSION $$VERSION > config.h)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.