[Qbs] Generated header files used by multiple products

Christian Kandeler christian.kandeler at qt.io
Wed Feb 7 11:14:04 CET 2018

On Wed, 7 Feb 2018 10:00:13 +0100
Christian Gudrian <christian.gudrian at aucos.de> wrote:

> In our project we are using a custom module to generate header files 
> with classes that descend from QObject.
> If a single product depends on this generator module everything works as 
> expected.  A second product, however, may not as well depend on the 
> generator module, as Qbs complains about duplicate output artifacts.  
> Without the explicit dependency to the generator module the second 
> product compiles nonetheless (as the header files have already been 
> generated).  But now it's the linker that complains about missing 
> symbols from the moc generated source files.
> How to share generated header files across products while pertaining moc 
> awareness?

Are you saying the rule in your module puts the header files at a project-global location? Then you cannot use it in more than one product, because it gets instantiated for every one of them.
The simplest way to deal with this is to create the headers per product. If the generator is expensive, you should turn it from a module into a product and export a rule that copies the header files into the importing product's build directory. In that case, only the copy should get the hpp tag.


More information about the Qbs mailing list