global vars in .pro file
-
Hi all, I need to deploy my qt application in various "version". The difference between this versions are only the repository where the application read the initial configuration.
My idea is to define a variable in the .pro, and then use this in my cpp code also.
(I have to change the "TARGET" in the .pro).
Is it possible?
What is the best solution? -
Hi,
Do you mean something like:
qmake MYCONFIG=foo
contains(MYCONFIG, foo) { TARGET = foo_bar }
?
-
Hi SGaist,
thanks for your support!I mean something like, in the .pro file:
TARGET = MYAPPNAME DEFINES+= MYTARGET="$${TARGET}"
I would use the MYTARGET in the cpp code, like this:
QString baseRepository = "/basepath/"+ MYTARGET;
Or something similar?
-
Hi,
What you could do is this in the .pro file:
TARGET = foo
DEFINES += MYTARGET="$(TARGET)"However then you need to make sure to use the MYTARGET define in your source code with some sort of stringify mechanism to turn it into a string. You find lots of hits if you search for "C++" and "Stringify", just like http://stackoverflow.com/questions/20384709/how-to-stringify-a-string-which-contains-a-comma
Is this what you are looking for?
-
The define itself will also need to escaped in order to have " correctly in the shell.