Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference external library dependencies in qt qbs?

Tags:

c++

qt

qbs

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!

like image 709
Tyler Daniel Avatar asked Sep 03 '15 05:09

Tyler Daniel


1 Answers

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" }
    }
}
like image 179
Johannes Matokic Avatar answered Nov 18 '22 04:11

Johannes Matokic