[Solved] qmake: variables scope



  • 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!



  • 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...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.