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)