Best way to set common include paths for all projects that have a cpp plugin applied

Hi,

I am trying to set common include paths for all projects that have a cpp plugin, what would be the best way to do this, I am using nightly build of gradle 2.4.

Regards, Ante Ilic

Hi Ante,

There are several ways, but it depends on how you’re planning to use the includes. If some of them will be optional, you might consider modelling all of the includes as several prebuilt libraries and then projects could opt-in with:

components {
        main(NativeExecutableSpec) {
            sources {
                cpp.lib library: 'someLib', linkage: 'api'
            }
        }
    }

If you only have one prebuilt library like this and it always makes sense to include it, you can hook into the binaries and add a dependency yourself. This works inside the model block and outside of it. Inside a component, it only applies to binaries produced by that component and at the top level it applies to all binaries produced by that project. You can select different binaries using the methods here.

You can also just dive into the arguments that will be passed to the particular compilers. This bypasses what Gradle knows about the arguments and might cause clashes.

HTH.

Thanks, Sterling