[Qbs] How to check whether a project is a subproject of another project?

Christian Kandeler Christian.Kandeler at qt.io
Wed Jul 17 18:07:59 CEST 2019


On Wed, 17 Jul 2019 23:25:49 +0800
Vincent Hui <vincenthk007 at gmail.com> wrote:

> I want to check whether a project is a subproject of another project. If a
> project is not a subproject, its examples and tests are built. If a project
> is a subproject, its examples and tests are not built.

Declare a property in your project that controls this. Override this property from the containing project. Done.

> It seems that the method for checking whether a project is a subproject is
> undocumented.

There is no such method, and I don't think it would be a good idea to have it.

> I came up with a method to check whether a project is a subproject. It is
> checking whether  sourceDirectory is equal to path. I tried a simple
> project, my method works.
> 
> "
> Project {
>     readonly property bool isSubProject: (sourceDirectory === path) ? false
> : true;
> ......
> "
> 
> Can my method work in complicated projects?

No. The parent project could be in the same directory.


Christian


More information about the Qbs mailing list