Tweak dependency's features depending on target_os

My library depends on gettext-rs, which in turn depends on gettext-sys. The latter has a useful feature, "gettext-system", which doesn't work on MacOS. I'd like to enable it for all other platforms, but Cargo doesn't support that yet. The suggested workaround is to create a dummy intermediate crate, but I can't get that to work—if even one of my crates enable the feature, all the crates get compiled with that feature. I think this is intentional (the build plan should be the same for the whole artifact, to avoid version mismatches), but I don't understand how I am supposed to implement the workaround then.

The setup for this is a bit unwieldy, so I put everything into a GitHub repository. Please clone https://github.com/Minoru/cargo_target_specific_features to see how I'm trying to implement this.

The most important part there is in my-library/Cargo.toml, where I pick different deps for different targets:

[target.'cfg(target_os = "macos")'.dependencies]
gettext-without-system = { path = "../gettext-without-system" }

[target.'cfg(not(target_os = "macos"))'.dependencies]
gettext-with-system = { path = "../gettext-with-system" }

Here's how I check if those lines are doing what I want:

$ cargo clean
$ rm -f Cargo.lock
$ cargo build --verbose 2>&1 | grep gettext-sys                                                                                                        ~/src/target_specific_features
   Compiling gettext-sys v0.19.8
     Running `rustc --crate-name build_script_build /home/minoru/.cargo/registry/src/github.com-1ecc6299db9ec823/gettext-sys-0.19.8/build.rs --color never --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="gettext-system"' -C metadata=6768bb2d1602e29e -C extra-filename=-6768bb2d1602e29e --out-dir /home/minoru/src/target_specific_features/target/debug/build/gettext-sys-6768bb2d1602e29e -L dependency=/home/minoru/src/target_specific_features/target/debug/deps --extern cc=/home/minoru/src/target_specific_features/target/debug/deps/libcc-460758b1ad89dc00.rlib --cap-lints allow`
     Running `/home/minoru/src/target_specific_features/target/debug/build/gettext-sys-6768bb2d1602e29e/build-script-build`
     Running `rustc --crate-name gettext_sys /home/minoru/.cargo/registry/src/github.com-1ecc6299db9ec823/gettext-sys-0.19.8/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="gettext-system"' -C metadata=400f28211b60e5ea -C extra-filename=-400f28211b60e5ea --out-dir /home/minoru/src/target_specific_features/target/debug/deps -L dependency=/home/minoru/src/target_specific_features/target/debug/deps --cap-lints allow`

You can see --cfg 'feature="gettext-system"' in there. The output stays the same even if I flip the conditions in my-library/Cargo.toml. The only way to get rid of that --cfg 'feature="gettext-system"' is to disable the feature in gettext-with-system, or to remove gettext-with-system from Cargo.toml files (so it's not even built). This defeats the purpose, since non-macOS targets won't have "gettext-system" enabled.

What am I misunderstanding and/or doing wrong?

In the end, I implemented a work-around specific to gettext-sys: I enabled gettext-system Cargo feature, but on macOS, I also set GETTEXT_BIN_DIR, GETTEXT_LIB_DIR, and GETTEXT_INCLUDE_DIR environment variables, pointing to gettext installed via Homebrew.