是否可以使用 Cargo 编译不包含 Cargo.toml 的外部 git 存储库?

Is it possible to compile an external git repository that doesn't contain Cargo.toml with Cargo?

我正在尝试在我的本地项目目录中克隆 SFML github repo 并使用 build.rs Cargo 解决方案构建它,但我收到此错误:

Could not find Cargo.toml

我没有找到任何方法从我自己的 Cargo.toml 配置中获取不包含 Cargo.toml 配置文件的存储库!

由于 SFML 不是 Rust 项目,您当然不能直接使用 cargo 构建它。但是在 build.rs 内,您可以轻松地 run 相应的 CMake 命令来执行构建。之后,您可能想在链接器搜索路径中添加一些东西——沿着这些行:

// build.rs
println!("cargo:rustc-link-search=native=/search/path/to/add");
println!("cargo:rustc-link-lib=static=sfml");