[Solved] qmake: variables scope
-
wrote on 4 Apr 2011, 06:40 last edited by
Hi all,
I have a strange problem with variables' scope.
I needed a simple function to append a directory to sources/headers, so what I did is:
@
defineTest(append_dir){
_DIR_NAME = $$1
_SOURCES = $$2
_HEADERS = $$2
for(a, $$_SOURCES):SOURCES += $${_DIR_NAME}$${a}
for(a, $$_SOURCES):HEADERS += $${_DIR_NAME}$${a}
}@
If I echo the SOURCES inside the function's scope it's fine but outside everything is undefined as if I'm dealing with a local variable! Am I missing something?
Thank you for your help! -
wrote on 5 Apr 2011, 11:32 last edited by
Well, I found the solution:
@defineTest(append_dir){
_DIR_NAME = $$1
_SOURCES = $$2
_HEADERS = $$2
for(a, _SOURCES):SOURCES += $${_DIR_NAME}$${a}
for(a, _SOURCES):HEADERS += $${_DIR_NAME}$${a}
export(SOURCES)
export(HEADERS)
}@
To bad that this neither documented in the Qt qmake documentation nor in the 'Undocumented qmake' web page...
1/2