Skip to content

flag for cargo add to add platform specific dependencies #11720

@bindsdev

Description

@bindsdev

Problem

Currently, there is no support for adding platform specific dependencies (such as [target.'cfg(windows)'.dependencies]) using cargo add.

Proposed Solution

Add a --cfg option that allows the user to specify the whole desired cfg predicate.

Examples:

  • cargo add windows --cfg windows
  • cargo add raw_cpuid --cfg any(target_arch = "x86", target_arch = "x86_64")

Notes

  • Currently, since cfg dependency specifications only are supported using platform predicates, one might think that the option should be named differently. But, in case other cfg pairs/options become supported in the future, the name of the flag allows for it to also include those without confusion for its name being named after the fact it specifies platform specific dependencies only.

Metadata

Metadata

Assignees

Labels

A-documenting-cargo-itselfArea: Cargo's documentationC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-add

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions