Read all includes from native binary

I have a simple project, with a few libraries and an executable:

model {
 components {
    myExec(NativeExecutableSpec) {
       sources {
            c {
                lib project: ":path:lib1", library: 'lib1', linkage: 'static'
                lib project: ":path:lib2", library: 'lib2', linkage: 'static'
          }
       }
      lib1(NativeLibrarySpec) {
          sources {
            c {
                exportedHeaderr {
                     srcDir "path1"
                     srcDir "path2"
                }

       }
      lib2 ....

How would it be possible to read all headers for binary? For each of library it’s an easy:

binaries.all  { 
            sources.withType(CSourceSet) { sourceSet ->
                println sourceSet.exportedHeaders.srcDirs
            }
      }

but it doesn’t take into account dependencies (libs), so on the application level headers paths from libraries are missed. There is getIncludeRoots function, but how could I use it there to get that information?