Need example build.gradle for C/C++ project with non-conventional directory structure

I’m having problems figuring-out how to tell gradle about the non-conventional directory structure of my C project. I’ve looked at the C/C++ documentation in the Gradle User Guide but it’s still not clear to me what I have to do.

If you can, would you please reply with an example “build.gradle” file for a C/C++ project with a non-conventional directory structure. Thanks.

There’s not yet a sample (or docs) that cover this scenario. However, this integration test should point you in the right direction (it includes a sample build file):

https://github.com/gradle/gradle/blob/master/subprojects/cpp/src/integTest/groovy/org/gradle/nativecode/language/cpp/CppPluginIntegrationTest.groovy#L50

The solution you referenced isn’t quite applicable because the relevant part is enclosed by a “def”. Still, it got me closer. See my followup posting for the current problem.

Here’s my current “build.gradle”

apply plugin: ‘cpp’

cpp {

sourceSets {

lib {

source.srcDirs = [“lib”]

}

}

}

binaries.all {

compilerArgs “-x c”, “-std=gnu90”

}

libraries {

foo {

source cpp.sourceSets.lib

}

}

And here’s my current problem:

:libExtractHeaders UP-TO-DATE

:compileUdunits2SharedLibraryg++: language c not recognized

g++: language c not recognized

g++: language c not recognized

g++: language c not recognized

cc1plus: warning: command line option “-std=gnu90” is valid for C/ObjC but not for C++

cc1plus: warning: command line option “-std=gnu90” is valid for C/ObjC but not for C++

/home/steve/udunits2/src/lib/unitToIdMap.h:25:5: error: variable or field ‘utimFreeSystem’ declared void

Apparently, the “cpp” plugin insists on using g++, which doesn’t work with my C code.