// tag::apply-plugin[]
apply plugin: 'cpp'
// end::apply-plugin[]

// tag::libraries[]
model {
    components {
        hello(NativeLibrarySpec)
    }
}
// end::libraries[]

// tag::executables[]
model {
    components {
        main(NativeExecutableSpec) {
// tag::source-library[]
            sources {
                cpp {
                    lib library: "hello"
                }
            }
// end::source-library[]
        }
    }
}

// end::executables[]

// tag::all-binaries[]
model {
    binaries {
        all {
            // Define a preprocessor macro for every binary
            cppCompiler.define "NDEBUG"

            // Define toolchain-specific compiler and linker options
            if (toolChain in Gcc) {
                cppCompiler.args "-O2", "-fno-access-control"
                linker.args "-Xlinker", "-S"
            }
            if (toolChain in VisualCpp) {
                cppCompiler.args "/Zi"
                linker.args "/DEBUG"
            }
        }
    }
}
// end::all-binaries[]

// For any shared library binaries built with Visual C++, define the DLL_EXPORT macro
model {
    binaries {
        withType(SharedLibraryBinarySpec) {
            if (toolChain in VisualCpp) {
                cppCompiler.define "DLL_EXPORT"
            }
        }
    }
}
