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 = [
          '-Wall',
          '-Werror',
          '-pedantic-errors'
      ]

     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 = [
  '--std=c++11'
]

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 ->
  binary.headerDirs.add('extra_include_dir')
} 

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