corrosion is a free, open source build & deployment project written in CMake and released under MIT. It has 1,518 GitHub stars, 157 forks and 71 open issues, and was last pushed 3 days ago. On this registry it ranks #55 of 84 tracked projects in Build & Deployment, with 5 head-to-head comparisons available. It gained 17 stars over the last 30 tracked days.

What is corrosion?

Corrosion is an MIT-licensed CMake package that imports Rust executables, static libraries, and dynamic libraries into an existing CMake build from a Cargo workspace or package manifest, and it is aimed at C and C++ teams that already build with CMake and want to add Rust code without replacing their build system.

What it is

Corrosion, formerly known as cmake-cargo, is a tool for integrating Rust into an existing CMake project. It lives in the CMake ecosystem, at the boundary between CMake and Cargo, and it automatically imports executables, static libraries, and dynamic libraries from a workspace or package manifest, meaning a Cargo.toml file. It is distributed under the MIT licence, so it can be vendored or installed without a commercial agreement.

The concrete problem it solves is the glue code that a mixed Rust and C/C++ project otherwise needs by hand. Without Corrosion, a CMake build must locate Cargo, invoke it through custom commands and custom targets, then locate the produced artifacts by hand and wire them into target_link_libraries calls, while also coping with multi-configuration output directories and cross-compilation toolchains. Corrosion replaces that hand-written plumbing with a single import call that reads the manifest and produces ordinary CMake targets that can be consumed and linked like any other target in the tree.

Key capabilities

  • Automatic import of executables, static libraries, and shared libraries from a Rust crate, so Rust artifacts become first-class CMake targets.
  • corrosion_import_crate(MANIFEST_PATH rust-lib/Cargo.toml) reads a package or workspace manifest and creates those targets in one call.
  • Linking in tree through standard CMake, as in target_link_libraries(your_cpp_bin PUBLIC rust-lib).
  • Multi-config generator support, so generated Debug and Release configurations are both handled rather than collapsed to a single build type.
  • Simple cross-compilation, so the same project can target non-host toolchains.
  • Easy installation of Rust executables as part of a CMake install step.
  • Several integration routes: the CMake FetchContent module, installing Corrosion, or adding it as a subdirectory.

Who uses it and how

  • C and C++ projects that already have a working CMake build and want to add a Rust crate as a static or shared library without duplicating the build logic.
  • Teams that vendor Corrosion through FetchContent_Declare pinned to a version tag such as v0.6, a commit hash, or a branch.
  • Projects that build through multi-config generators and need both Debug and Release variants of the imported Rust targets.
  • Projects that cross-compile and want the Rust portion built for the same target platform as the C/C++ portion.
  • Workspaces containing several crates, where the manifest is read once and the individual binaries and libraries are exposed as separate targets.

Getting started

The documented route is CMake FetchContent: declare Corrosion with GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git and a GIT_TAG such as v0.6, then call FetchContent_MakeAvailable(Corrosion) and import the crate with corrosion_import_crate(MANIFEST_PATH rust-lib/Cargo.toml). Installing Corrosion or adding it as a subdirectory is covered in the setup chapter of the documentation; the v0.6 release requires CMake 3.22 or newer, and Rust 1.46 or newer, with some platforms needing a more recent Rust version.

How it compares

No comparable products are listed in the facts for this entry, so Corrosion stands alone in this registry. Its distinguishing position is narrow by design: it does not try to be a general build system, it targets the CMake side of the CMake–Cargo boundary.

When to use it — and when not to

A self-hoster must operate a Rust toolchain alongside CMake, keep the toolchain and cargo registry access working in continuous integration, and accept the version floor of CMake 3.22 for the v0.6 release. It is the wrong choice for a project that does not already build with CMake, or one pinned below CMake 3.15, since the v0.5 line receives critical backports only and newer features may require more recent CMake. The README excerpt is short and defers most detail to the external documentation site, and the repository carries a nontrivial open issue count, so teams should budget time for reading the setup chapter rather than assuming the front page is sufficient.

project readme (upstream, from github) — read inline

Corrosion

Build Status Documentation License

Corrosion, formerly known as cmake-cargo, is a tool for integrating Rust into an existing CMake project. Corrosion can automatically import executables, static libraries, and dynamic libraries from a workspace or package manifest (Cargo.toml file).

Features

  • Automatic Import of Executable, Static, and Shared Libraries from Rust Crate
  • Easy Installation of Rust Executables
  • Trivially Link Rust Executables to C/C++ Libraries in Tree
  • Multi-Config Generator Support
  • Simple Cross-Compilation

Sample Usage with FetchContent

Using the CMake FetchContent module allows you to easily integrate corrosion into your build. Other methods including installing corrosion or adding it as a subdirectory are covered in the setup chapter of the corrosion documentation.

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)

Requirements

v0.6 Release

  • CMake 3.22 or newer

v0.5 Release (Critical backports only)

  • CMake 3.15 or newer. Some features may only be available on more recent CMake versions
  • Rust 1.46 or newer. Some platforms / features may require more recent Rust versions

Frequently asked questions

Is corrosion free to use?

corrosion is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does corrosion do?

Marrying Rust and CMake - Easy Rust and C/C++ Integration!

What is corrosion written in?

corrosion is primarily written in CMake. Its source is publicly available at https://github.com/corrosion-rs/corrosion, and it has 1,518 GitHub stars.