QMake: Use string as variable
Unsolved
General and Desktop
-
Hello,
I have a string and I want to use it as part of another variable name
QT_MODULE_NAME = xml # I would like to use something like this: LIB_PATH = $${QT.$${QT_MODULE_NAME}.libs}
But it does not seem to work. I get
Missing } terminator
Any tips?
-
I don't think qmake supports nesting variable names like that. One thing you could try is to use different scoping methods:
LIB_PATH = $${QT.$${QT_MODULE_NAME}.libs} # Or LIB_PATH = $${QT.$$(QT_MODULE_NAME).libs} # Or LIB_PATH = $${QT.${QT_MODULE_NAME}.libs}
Dig through qmake documentation, maybe it will help.
Alternative would be to build an array and iterate over it, like:
QT_MODULE_NAMES = QT.xml QT.widgets QT.networking QT_MODULE_NAMES += QT.gui for (module, QT_MODULE_NAMES) { LIB_PATH=module.libs }
I have no idea if it will work with variable names - I doubt it.