Marrying Rust and CMake - Easy Rust and C/C++ Integration!
| Files | Last commit | Last update |
|---|---|---|
| 9 months ago | ||
| 3 months ago | ||
| 7 months ago | ||
| 9 months ago | ||
| 2 years ago | ||
| 7 months ago | ||
| 1 year ago | ||
| 8 years ago | ||
| 9 months ago | ||
| 7 months ago |
Translated by AI, submit an issue feedback
Corrosion
Corrosion,前身为 cmake-cargo,是一款用于将 Rust 集成到现有 CMake 项目中的工具。Corrosion 能够从工作区或包清单(Cargo.toml 文件)自动导入可执行文件、静态库和动态库。
特性
- 从 Rust Crate 自动导入可执行文件、静态库及共享库
- Rust 可执行文件的便捷安装
- 轻松将 Rust 可执行文件与项目中的 C/C++ 库进行链接
- 多配置生成器支持
- 简单的交叉编译
使用 FetchContent 的示例
借助 CMake 的 FetchContent 模块,您可以轻松地将 corrosion 集成到构建过程中。其他方法(包括安装 corrosion 或将其作为子目录添加)在 corrosion 文档的设置章节中有详细介绍。
include(FetchContent)
FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.6 # 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)
要求
v0.6 版本
- CMake 3.22 或更高版本
v0.5 版本(仅关键回溯)
- CMake 3.15 或更高版本。部分功能可能仅在更新的 CMake 版本中可用
- Rust 1.46 或更高版本。部分平台/功能可能需要更新的 Rust 版本
Introduction
嫁给Rust与CMake —— 轻松实现Rust与C/C++的融合!【此简介由AI生成】
MIT CMake674Commitsbuild-systembuild-systemsbuild-toolccargocmakecmake-cargocpluspluscppcross-compilationrust
Customize your domain