qtqt-creatorqbs

How do I use a different library path for 32-bit builds in QBS?


In my QBS file I currently have:

cpp.libraryPaths: ["C:/Foo/x64/lib"]

which works OK with the 64-bit MinGW-w64 kit auto-detected by QT Creator.

But building with the 32-bit kit fails since the 32-bit libraries are in a different directory C:/Foo/i686/lib.

How do I configure it so that a different library path is used if the 32-bit MinGW-w64 kit is selected?

Bonus question: I'd like to get the base path C:/Foo from some local setting too, because on another development system I have the libraries in a different base path, not C:/Foo. Is that possible?


Solution

  • For the custom lib path on different machines, you can have a property that is set by passing a parameter to qbs if necessary:

     property path libPath: "C:/Foo"
    

    And then qbs build blahblah project.libPath:/path/to/lib

    In order to detect the build type, you can use the following format:

        Properties {
            condition: qbs.targetOS.contains("windows") && qbs.architecture === "x86"
            cpp.libraryPaths: [libPath + "/i686/lib"]
        }
        Properties {
            condition: qbs.targetOS.contains("windows") && qbs.architecture === "x86_64"
            cpp.libraryPaths: [libPath + "/x64/lib"]
        }
    

    If you don't invoke qbs manually, you could set the parameter inside the project settings, however I feel like this kinda defeats the purpose if you have to change it on different machines.

    In this regard, it would be better to set the libPath as an environment variable. Then simply read it via Environment.getEnv("varName").