apply plugin: "cpp"

model {
    components {
        main(NativeExecutableSpec) {
            binaries.all {
                // Define a preprocessor macro
                cppCompiler.define "NDEBUG"
                // Add some additional compiler arguments
                if (toolChain in Gcc) {
                    cppCompiler.args "-fno-access-control", "-fconserve-space"
                }
            }
        }
    }
    tasks { t ->
        $("components.main").binaries { binaries ->
            binaries.values().each { binary ->
                def stripTask = "strip${binary.name.capitalize()}"
                t.create(stripTask) {
                    dependsOn binary.tasks.link
                    doFirst {
                        if (binary.toolChain in Gcc) {
                            ["strip", binary.tasks.link.outputFile].execute()
                        }
                    }
                }
                binary.tasks.build.dependsOn stripTask
            }
        }
    }
}
