Native binaries: add to binary configuration in subproject

I need to build a large source tree containing multiple C++ projects. I’d like to have a top level build file that defines build conventions such as common include directories and compiler / linker flags, and then be able to override or add to the conventions at the subproject level.

I was able to add to the compiler / linker flags as follows:

Top level build file:

subprojects {
      apply plugin: 'cpp'
      ext.commonCompilerArgs = [

     components {
        binary(NativeLibrarySpec) {
          sources {
            cpp {
              source {
                srcDir 'src'
                include '*.cpp'

              exportedHeaders {
                srcDir 'include'
                include '*.h'
     binaries.withType(NativeLibraryBinarySpec) {
          // Compiler args
          commonCompilerArgs.forEach { compilerArg ->
          cppCompiler.args << compilerArg

Subproject build file:

def extraCompilerArgs = [

binaries.all {
  extraCompilerArgs.each { arg ->
    cppCompiler.args << arg

However, I’m unable to apply the same principle to add extra include directories (to be added to the compiler arguments). I tried this in the subproject build file:

binaries.withType(NativeLibraryBinarySpec) { binary ->

but it doesn’t add the extra directory. What am I doing wrong here ?