[Qbs] Building more than one binary from the same sources with multiplexing

Christian Kandeler christian.kandeler at qt.io
Tue Sep 4 17:50:31 CEST 2018


On Tue, 4 Sep 2018 17:27:16 +0200
Алексей Скородумов <2350266 at gmail.com> wrote:

> > (I assume here that you want to build ony a selected subset of products
> > twice. Otherwise, you should of course rather build the project for two
> > different configurations:
> > $ qbs build config:configBar cpp.defines:BAR config:configFoo
> > cpp.defines:FOO)
> 
> 1. Why is it better?

Simply because this approach matches what should be achieved, namely building the entire project for two different configurations. But again, if you really want to build only selected products twice, then your approach is perfectly fine.

> 2. I have tried to do this inside project file and I got the following:
> 
> CppApplication {
>     name: "foo-bar"
>     multiplexByQbsProperties: ["buildVariants"]
>     qbs.buildVariants: ["FOO", "BAR"]

That's likely to lead to unexpected results, as qbs only expects the values "debug" and "release" here.

>     property var cppDefines: {
>         var defines = [];
>         if (qbs.buildVariant === "FOO")
>             defines.push("FOO");
>         if (qbs.buildVariant === "BAR")
>             defines.push("BAR")
>         return defines;
>     }
> 
>     cpp.defines: cppDefines
>     files: [
>         "main.cpp"
>     ]
> }
> 
> It works, but while building from QtCreator I always get a release build. What
> is wrong here?

What did you expect to happen?


Christian



More information about the Qbs mailing list