Denis Rouzaud
Denis Rouzaud

Reputation: 2630

overwrite qmake variable from command line

In a Qt project, I have a variable I use in the code. This is done by using

APP_NAME = "QField"
DEFINES += "APP_NAME=\"\\\"$${APP_NAME}\\\"\""

How can I modify this from the command line?

I tried to add APP_NAME=my_name in additional arguments of qmake build steps without success.

Note: the APP_NAME and DEFINES lines are within a .pri file which is included in the .pro file called by qmake.

Upvotes: 2

Views: 966

Answers (1)

Matt
Matt

Reputation: 15196

How can I modify this from the command line?

Simply by specifying APP_NAME=my_name on the qmake's command line.

I tried to add APP_NAME=my_name in additional arguments of qmake build steps without success.

That's because of the subsequent overwriting the variable inside your .pro/.pri file. You should add the condition to prevent that:

#APP_NAME = "QField"
!defined(APP_NAME, var):APP_NAME = "QField"

Upvotes: 5

Related Questions