Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Solved] qmake: variables scope

[Solved] qmake: variables scope

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 2.6k Views
  • 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 Offline
    D Offline
    dword
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      dword
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved