Conditionally Compiling a Crate in a Workspace

Is is possible to conditionally compile a member of a workspace. For example, given:

[workspace]
members = [
    "crate-a",
    "crate-b",
    "crate-c",
    "picky-crate",
]

Can I somehow make the picky-crate only compile in the presence of cfg=pickycrate="true")?

1 Like

You can use -p Cargo flag to compile a chosen crate.

If crates are dependencies of each other, you can make picky-crate an optional dependency enabled by a Cargo feature.

There's default-members workspace field Workspaces - The Cargo Book

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.