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

Christian Kandeler christian.kandeler at qt.io
Tue Sep 4 16:14:38 CEST 2018

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

> I would like to build several binaries from the same sources with different
> compiler settings (defines). Is this a correct way to go:
> import qbs
> CppApplication {
>     name: "foo-bar"
>     multiplexByQbsProperties: ["profiles"]
>     Profile {
>         name: "foo"
>         cpp.defines: ["FOO"]
>         baseProfile: project.profile
>     }
>     Profile {
>         name: "bar"
>         cpp.defines: ["BAR"]
>         baseProfile: project.profile
>     }
>     qbs.profiles: ["foo", "bar"]
>     files: [
>         "main.cpp"
>     ]
> }

Yes, this looks correct.
(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)

> Also, I noticed that without specifying baseProfile: project.profile
> property qbs silently switches to a default profile

Not the default profile; that's the value of preferences.defaultProfile. What you mean is that all properties except the one you set in the profile get their default values. That's exactly the same behavior as for any other profile, whether created with qbs-config, qbs-setup-toolchains, or with a Profile item.

> regardless of active profile in QtCreator. Is it a bug or feature?

A feature. You specifically request a custom profile, and that's what you get. We don't want it to get "polluted by default". As you have found out, you can easily opt in to inheriting from the project's main profile.


More information about the Qbs mailing list