Create src/main/hello.cpp that behaves differently when EXTRA_CHEERY is defined. Build with the following:
apply plugin: 'cpp'
executables {
hello
helloCheery
}
sources {
helloCheery {
cpp {
source {
srcDir "src/hello/cpp"
}
}
// affects all binaries, not just helloCheery
binaries.all {
cppCompiler.define 'EXTRA_CHEERY'
}
}
}
observe that both executables, not just helloCheery, were built with -DEXTRA_CHEERY.