My cargo.toml
is:
bin = [
{ name = "first", path = "bin/first.rs" },
{ name = "second", path = "bin/second.rs" },
]
[lib]
name = "some_lib"
crate-type = [
"cdylib",
"rlib",
]
[target."cfg(windows)".build-dependencies]
winresource = "0.1"
When compiled, two executables are generated: first.exe
and second.exe
. In order to have custom icons for the executables on windows, I use the following build.rs
script:
use std::io;
#[cfg(windows)] use winresource::WindowsResource;
fn main() -> io::Result<()> {
println!("cargo:rerun-if-changed=build.rs");
#[cfg(windows)] {
WindowsResource::new()
// This path can be absolute, or relative to your crate root.
.set_icon("icon_for_first.ico")
.compile()?;
}
Ok(())
}
This applies the resource to every executable, rather than just first.exe
. Is there a way to check the target that is being compiled?