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] system environment variables in QBS
QtWS25 Last Chance

[SOLVED] system environment variables in QBS

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 4.8k 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.
  • W Offline
    W Offline
    WoJo
    wrote on last edited by
    #1

    Hi,
    I hope this is the correct forum.

    I am trying to set up a QBS build environment for a project. I use an external library (OpenCV), if I set the include and library path absolut it works all fine. But other developers of the team may have installed the library in a different path. so we decided to set the path to the library in an system environment variable and use this variable in the qbs file. in qmake files this works fine, but I was not able to figure out how to use environment variables in .qbs files. I tried (one at a time):

    @cpp.includePaths[ $OPENCV ]
    cpp.includePaths[ $(OPENCV) ]
    cpp.includePaths[ $$OPENCV ]
    cpp.includePaths[ OPENCV ]@

    I always got the error "Variable XXX not found" (XXX is what I wrote between the brackets). the system variable is set, if I echo the variable in the terminal, I get the correct path. qmake with the same variable works fine.
    How do I use environment variables correctly in QBS? I found not a single word about it in the (in my opinion very bad) documentation.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      WoJo
      wrote on last edited by
      #2

      I figured it out my self:

      @qbs.getenv("VAR_NAME")@

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        in qbs 1.3 it is clearly stated in docs

        @qbs.getEnv(name)@ (second letter "e" is Capitalized)

        In my case following worked:

        @property string gmockHome: qbs.getEnv("GMOCK_HOME")
        cpp.includePaths: ['.', gmockHome + '/include', gmockHome + '/gtest/include']@

        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