Configuring cpp sources in gradle

I created a project on top of Qt (so the source is written in C ++), and I wanted to try Gradle to automatically build on it. It took me a while to get detailed information on setting up a multi-project build (there is an executable file and two libraries), and now I'm trying to tell the cpp-exe and cpp-lib plugin how my source tree is structured.

I set up a task that should print all the source sets (should there be at least default permissions?), And it looks like this:

 task projectinfo { description = "Informations about the current project" group = INFORMATIONS_GROUP doFirst { task -> print ("""${task.project.sourceSets.all}""") } 

If I run this task, Gradle tells me that there is no "sourceSets" property for the project. The plugin documentation tells me that you can configure the location of the sources, but not how.

So my question is: how can I tell the Gradle cpp plugin which source files to use. If there is any documentation on the cpp plugin other than API documentation, and a Gradle user guide that will also help.

+7
source share
1 answer

Take a look at using Adam Murdoch Gradle cpp plugin . I believe that he is one of the main Gradle senders, so he should know how to use this better than anyone:

Run native-platform / build.gradle

 cpp { sourceSets { main { source.exclude 'curses.cpp' } curses { source.srcDirs = ['src/main/cpp'] source.include 'curses.cpp' source.include 'generic.cpp' source.include 'generic_posix.cpp' } } } Then, within the 'libraries' node, refer to all/any combination of architecture and source sets: sourceSets << cpp.sourceSets.main sourceSets << cpp.sourceSets.curses 

I haven’t looked at it for too long, but it looks like it determines which source code based on the OS architecture includes the combinations and stores them in the options variable. Then it processes them in the platform JAR (I have not yet run the build, perhaps it should).

Also, see https://github.com/rklaren/GradleJNI , it uses the cpp plugin, but it looks a bit Windows oriented.

Update . I also found https://github.com/alkemist/gradle-cpp-demo , which has an example of the 'cpp-exe' plugin that creates an executable file.

+9
source

All Articles