I’ve been running into some frustration lately with crates that require CMake installed in order to compile. I don’t have CMake installed on my Windows machine by default, so any crate that needs CMake, directly or indirectly, won’t compile for me.
I ran into this when trying to run one of the examples for amethyst. In trying to use cargo-tree to investigate which crate was pulling in CMake as a dependency, I found that cargo-tree also depends on CMake!
As a Rust developer, this is frustrating to experience because one of the things that makes Rust development so enjoyable is how well Cargo works as a self-contained build tool. Being able to add a single line to my
Cargo.toml to pull in a new dependency is great, and listing all dependencies in one file guarantees that I can always build my project on a new development machine. Including CMake (or any third party dependency that isn’t controlled by Cargo) throws a wrench in this, because now my project depends on something I need to install manually on each new development machine.
Ultimately this is a papercut: I could just install CMake and move on. But this is an issue that creates a barrier (however small) for new Rust developers, and I’d like to keep the on-boarding process as simple as possible for new developers on my projects. What are the possible solutions here?
- Build my crate in Docker, that way the entire build environment can be controlled (not actually a solution for me since I need to be able to build for Windows).
- Include build steps in the README that tell people to install CMake before building (not ideal,
cargo buildis the universal build process for Rust projects and any deviation makes it harder for new devs to get started).
- Provide the cmake crate with some way to automatically install CMake on dev machines.
- Create a Rust port of CMake that can be built and run by Cargo without needing an external dependency (seems like a wildly impractical solution).
- Install CMake with Rust, similar to how the Visual Studio Build Tools get install automatically when using the MSVC toolchain on Windows.
- Never have crates depend on a C/C++ library that uses CMake (even more wildly impractical than porting CMake to Rust).
The solution that seems the most effective would be to install CMake with Rust, though I have no idea how practical that would be to do (or if CMake is even a common enough dependency to justify doing so).
Any thoughts on this issue? Is this something that other people have run into? Or am I making I a fuss about a minor inconvenience?