Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] qmake: variables scope

    Tools
    1
    2
    2467
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dword 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!

      1 Reply Last reply Reply Quote 0
      • D
        dword 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 Reply Last reply Reply Quote 0
        • First post
          Last post