C++ with gradle

c++, gradle

Solution

put this in build.gradle

apply plugin: 'cpp'
executables {
   hello {}
}

put your source file in src/hello/cpp/say_hello.cpp

run 'gradle helloExecutable'

your executable should be built to build/binaries/helloExecutable/hello

Or, if you want your source in src/foo/bar then add

sources {
    hello {
      cpp {
        source {
            srcDir "src/foo/bar"
        }
    }
}

Problem

In Gradle 1.10 Release notes http://www.gradle.org/docs/current/release-notes I see C++ build mentioned. How to set up C++ project to build with gradle? (without IDE) Suppose I have ``` ProjectFolder/hello.cpp ProjectFolder/build.gradle ``` `hello.cpp`: ``` #include <stdio.h> #include <stdlib.h> int main(void) { puts("Hello World!!!"); return EXIT_SUCCESS; } ``` What should basic `build.gradle` be for this C++ project? UPDATE: I have already looked at Chapter 72 of User Guide and 2 year old examples mentioned. They don't make it simpler but more complicated. There is 1 file example with 6 lines. I haven't been touching C++ for 10 year and I just wanted quick start e.g. with GCC . (Not yet found)

Original source