Search code examples
qbs

Group Item: cannot install file to same location


In my project, I have several plugins depending on a single module, containing a Group item similar to:

Group {
    name: "group"
    qbs.install: true
    qbs.installDir: "../"
    files: <filename>
}

But compilation fails with "error: Cannot install files 'filename' and 'filename' to the same location 'location'". Basically, qbs cannot copy same file to same location twice (seems illogical to me)

How can this bug be resolved or is there any elegant workaround?


Solution

  • There is a workaround, which may require some restructuring of a project:

    instead of:

    Module {
        name: "somemodule"
    
        // module properties set to dependant products
    
        Group {
            // files to install
            qbs.install: true
        }
    }
    

    we can use:

    Product {
        name: "somemodule"
    
        Group {
            // files to install
            qbs.install: true
        }
    
        Export { 
            // module properties set to dependant products
        }
    }
    

    This way, files are only installed once when steps for mymodule are run, thus eliminating the conflict. Module properties, exported via Export Item, work just as ones exported via Module.

    Limitations:

    1. Product has to be added to references of the Project Item
    2. Modules cannot depend on Product Items, which may require to restructure all dependant modules into Project/Export pairs too