简体   繁体   中英

How to reference external library dependencies in 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!

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. Eg 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" }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM