[SOLVED] system environment variables in QBS

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

  • I figured it out my self:


  • 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']@

Log in to reply