[Qbs] Define the link order without an explicit dependency

Christian Kandeler Christian.Kandeler at qt.io
Fri Aug 9 12:34:35 CEST 2019


On Fri, 9 Aug 2019 02:15:31 +0200
Richard Weickelt <richard at weickelt.de> wrote:

> I have the following scenario:
> 
>     Product {
>         name: "some-headers"
>     }
> 
>     // Implementations of some-headers
>     // A-1 and A-2 define the same symbols and are mutually exclusive.
>     // An application product can only depend on one of them at a time
>     StaticLibrary {
>         name: "A-1"
>         Depends { name: "some-headers" }
>     }
>     StaticLibrary {
>         name: "A-2"
>         Depends { name: "some-headers" }
>     }
> 
>     // Can be linked to both, A-1/2
>     // But it must always appear after A-1/2 on the linker command line
>     // of a dependent application.
>     StaticLibrary {
>         name: "B"
> 
>         // Not sufficient to make B link after A-1/2
>         Depends { name: "some-headers" }
> 
>         // Can not do that because it would make "app" link to both
>         // A-1 and A-2 to app.
>         // Depends { name: "A-1" }
>         // Depends { name: "A-2" }

Why not have a central property that controls these dependencies everywhere?
Can be done without redundant code via a proxy product:

Product {
    name: "A"
    property string libAVariant: "a1"
    Export {
        Depends { name: "A-1"; condition: product.libAVariant === "a1" }
        Depends { name: "A-2"; condition: product.libAVariant === "a2" }
    }
}

And just depend on A everywhere. The libAVariant property could also be in a Project item or some helper module.
    

Christian


More information about the Qbs mailing list