7

Let's say I've downloaded some library xyz with headers and binaries and put it somewhere not in standard search paths. For each Product I can add the search paths and library to link to cpp.includePaths, cpp.libraryPaths, cpp.staticLibraries, etc.

Is there a better [standard] way to do this? If I'm building the library as part of my project it seems I can define the paths in an Exports item and then use a Depends item in each Product to automatically set the paths. This seems like a nice mechanism and I wonder if there isn't a way to use it for external dependencies as well.

The qbs docs are a little thin...

Thanks!

Tyler Daniel
  • 656
  • 6
  • 15

1 Answers1

7

You would typically create your own module for xyz. You can add locations where QBS would search for modules and imports by setting the project's qbsSearchPaths-property. E.g. by setting it to "qbs" QBS would search for additional modules in the "qbs/modules" sub-directory of your project.

There you could place a file called "xyz.qbs" that would look like this:

import qbs
Module {
    Depends { name: "cpp" }
    property string xyzPath: "the/xyz/path"
    cpp.includePaths: xyzPath + "/include"
    cpp.libraryPath: xyzPath + "/lib"
    cpp.staticLibraries: "xyz"
}

You could then use it by simply adding a Depend to your project:

import qbs
Project {
    qbsSearchPaths: "qbs"
    CppApplication {
        name: "myApp"
        files: "src/**"
        Depends { name: "xyz" }
    }
}
Johannes Matokic
  • 892
  • 8
  • 15
  • Thanks! I had eventually figured this out and then.. forgot that I had asked this question. I didn't know about qbsSearchPaths, though.. handy! – Tyler Daniel Nov 17 '15 at 20:57