Pergunta

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.

Foi útil?

Solução 2

@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

Outras dicas

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.

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

system(echo \\$${LITERAL_HASH}define VERSION $$VERSION > config.h)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top