> 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.

Thanks for your reply. You are suggesting to switch libAVariant globally and
I can see how that would work.

My project consists of multiple products where some have a dependency on
libAVariant "a1" whereas others have a dependency on "a2". If I apply your
suggestion, I would only be able to build either apps depending on "a1" or
"a2" at a time, but not both.

I was able to work around the problem by linking against the whole library
a1 or a2 in the app:

    Product {
        name: "a-headers"
    }

    StaticLibrary {
        name: "a1"
        Depends { name: "a-headers" }
    }

    StaticLibrary {
        name: "a2"
        Depends { name: "a-headers" }
    }
    StaticLibrary {
        name: "b"
        Depends { name: "a-headers" }
    }

    Application {
        name: "someapp-with-a1"
        Depends { name: "a1"; cpp.linkWholeArchive }
        Depends { name: "b" }
    }

    Application {
        name: "someapp-with-a2"
        Depends { name: "a2"; cpp.linkWholeArchive }
        Depends { name: "b" }
    }

That way the link order doesn't matter anymore. Not 100% optimal, but it works.

_______________________________________________
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs

Reply via email to