0

Assuming I have some project with tons of sub-projects, and in most cases I only need to compile few of them at once:

Project {
    property stringList plugins: ["plugin3", "plugin4"] // this is set externally
    references: plugins.map(function(p) { return "plugins/"+p+".qbs" })
}

Assuming plugin3 depends on plugin1 and plugin2:

Depends { name: "plugin1" }
Depends { name: "plugin2" }

In that case, I would have to set plugins property as:

plugins: ["plugin1", "plugin2", "plugin3", "plugin4"]

which is what I want to avoid. So, the question is: Is there a way to make subproject dependencies automatically added as project references?

p.s. there is also an alternative way to make all sub-projects present, but conditionally disabled. Can I somehow make them enabled by dependent sub-project?

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
Andrei R.
  • 2,374
  • 1
  • 13
  • 27

1 Answers1

0

references should pretty much always be a static list; there is no need to make it conditional just because you only want to compile a certain subset of your products at once.

Instead, what you'll want to do is run qbs with the -p option which lets you specify the name of a particular product to build. Using this option will only built that product and its dependencies, but not the rest of the products in your project.

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
  • is it possible to set products passed to `-p` from project file or by settings project properties? – Andrei R. Feb 09 '17 at 06:26
  • No, and there is no reason why you'd want to do that. However, if you're looking to exclude certain products from being built by default when you run `qbs build`, you can set the `builtByDefault` property of those products to `false`. – Jake Petroules Feb 09 '17 at 17:59
  • well, reasons are there when it comes to working in QtCreator. Basically, it's easier to set up references abovementioned way, than to manually run `qbs` – Andrei R. Feb 10 '17 at 01:20
  • Well, in Qt Creator you can simply right click on a particular target to build only that target and its dependencies. – Jake Petroules Feb 10 '17 at 02:06