# How to I add an icon to my c++ executable using Gradle?

I want to add an icon to my cpp executable (.exe). I can't seem to find anything regarding it. I'm using the cpp plugin in Gradle. I have a folder in the project directory called etc with an icon in it. I have seen posts how to do it in visual studio or eclipse but I want to do it in Gradle so when I build, the executable with already have the icon.

My code:

apply plugin: 'cpp'

model {
components {
main(NativeExecutableSpec) {
sources {
cpp {
source {
srcDirs "${projectDir}\\source" include "**\\*.cpp" } exportedHeaders { srcDirs "${projectDir}\\source"
include "**\\*.h"
}
}
}
}
}

platforms {
windows_x86 {
operatingSystem "windows"
architecture "x86"
}
}

repositories {
libs(PrebuiltLibraries) {
def libDir = "${projectDir}\\lib\\" ms { binaries.withType(SharedLibraryBinary) { sharedLibraryFile = file(libDir + "ms.dll") sharedLibraryLinkFile = file(libDir + "ms.lib") } } conf { binaries.withType(SharedLibraryBinary) { sharedLibraryFile = file(libDir + "conf.dll") sharedLibraryLinkFile = file(libDir + "conf.lib") } } supp { binaries.withType(SharedLibraryBinary) { sharedLibraryFile = file(libDir + "supp.dll") sharedLibraryLinkFile = file(libDir + "supp.lib") } } } } toolChains { mingw_x86(Gcc) { path "C:\\MinGW\\bin" eachPlatform() { cCompiler.executable "gcc" cppCompiler.executable "g++" linker.executable "g++" assembler.executable "as" staticLibArchiver.executable "ar" } target("windows_x86") } } binaries { withType(NativeExecutableBinarySpec) { if (toolChain in Gcc) { cppCompiler.args "-m32" cppCompiler.args "-c" cppCompiler.args "-w" cppCompiler.args "-I${projectDir}\\include"
cppCompiler.args "-std=c++11"
cppCompiler.args "-MMD"
cppCompiler.args "-MP"