How to declare different dependencies for multiple binaries

I have one Rust project that compiles to 2 different binary files (one is a CLI and one is a GUI app). The GUI app requires dependencies on tauri but the CLI does not. How should I declare the Cargo.toml to achieve that? Thanks

A part of the Cargo.toml

[[bin]]
name = "app"
path = "src/main.rs"

[[bin]]
name = "cli"
path = "src/cli.rs"

[dependencies]
// The stuff here are shared between both binaries

You would need to use a workspace instead to do that.

1 Like