Automatically use CMake for Windows builds #672
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the
rdkafka-sys/build.rs
script to automatically choose CMake if the target platform is Windows. Thecmake-build
cargo feature no longer has an effect on Windows. It can still be used to select the CMake build for other targets. The official rdkafka build system remains the default for other targets.This solves a number of problems:
rdkafka
/rdkafka-sys
no longer have to conditionally enablecmake-build
when they reference the crates just to have something that compiles across platforms.rdkafka-sys/build.rs
script fails. In RustRover, even if you otherwise enable thecmake-build
feature, there is an early "disovery" execution of the project that uses default features and fails miserably.I had initially tried to use the
cmake-build
feature, but there doesn't seem to a reliable mechanism to conditionally add a default feature. One option is to exploit a side effect of the v1 feature resolver: in therdkafka
crate, if we add a dependencies section that is conditional ontarget_os = "windows"
and passcmake-build
as a feature tordkafka-sys
, that feature accidentally remains enabled even if you runcargo test --package rdkafka-sys
from the root. This is definitely fixed in the v2 feature resolver, though.