Is it possible to include cargo packages in the workspace conditionally or tell cargo inside the package Cargo.toml file to ignore them?
Let's say I have a workspace with packages, which should be compiled only on a suitable platform.
[workspace]
members = [
"main",
"lib_common",
"lib_linux_only",
"lib_macos_only",
]
All lib pakages are dynamic libraries, so it's OK that some of them won't build on all platforms (because the main executable will know at runtime which of them to load or not). But it should happen "silently".
In the platform specific modules I have a conditional compilation check like
#[cfg(not(target_os = "linux"))]
compile_error!("This feature requires Linux");
that means I cannot run the main executable because the platform specific packages cannot be built. I have to comment out the linux package on mac and the mac package on linux in that case.