corrosion
v0.5.0
腐蚀,以前称为Cmake-Cargo,是将Rust整合到现有CMAKE项目中的工具。腐蚀可以自动从工作区或软件包清单( Cargo.toml文件)中导入可执行文件,静态库和动态库。
使用Cmake FetchContent模块,您可以轻松地将腐蚀整合到构建中。腐蚀文档的设置章节涵盖了其他方法,包括安装腐蚀或将其添加为子目录。
include (FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here
)
FetchContent_MakeAvailable(Corrosion)
# Import targets defined in a package or workspace manifest `Cargo.toml` file
corrosion_import_crate(MANIFEST_PATH rust-lib/Cargo.toml)
add_executable (your_cpp_bin main.cpp)
target_link_libraries (your_cpp_bin PUBLIC rust-lib)