# Best way to support Rust Language

**URL:** https://discourse.cmake.org/t/best-way-to-support-rust-language/1108
**Category:** Code
**Created:** [April 26, 2020, 11:03am UTC](https://discourse.cmake.org/t/best-way-to-support-rust-language/1108 "2020-04-26T11:03:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yashi](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yashi/32/557_2.png) [@yashi](https://discourse.cmake.org/u/yashi)
#### Post date: [April 26, 2020, 11:03am UTC](https://discourse.cmake.org/t/best-way-to-support-rust-language/1108/1 "2020-04-26T11:03:20Z")

</div>

By checking [enable\_language()](https://cmake.org/cmake/help/latest/command/enable_language.html), CMake doesn’t seem to support Rust. What would be the current best way to mix Rust with C project? Especially most of the code is written in C but would like to use a few libraries written in Rust.

Quick search shows me that many projects are using [ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html#id1).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 27, 2020, 2:05pm UTC](https://discourse.cmake.org/t/best-way-to-support-rust-language/1108/2 "2020-04-27T14:05:00Z")

</div>

I suggest using an `add_custom_command` to run `cargo` to make the Rust cdylib. You should be able to make an `INTERFACE` library representing that build then.

---

<div class="post-metadata">

### Author: ![yashi](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yashi/32/557_2.png) [@yashi](https://discourse.cmake.org/u/yashi)
#### Post date: [May 6, 2025, 11:23am UTC](https://discourse.cmake.org/t/best-way-to-support-rust-language/1108/3 "2025-05-06T11:23:39Z")

</div>

Just adding a few links to related posts:

- [`enable_language` option for Rust/Cargo](https://discourse.cmake.org/t/enable-language-option-for-rust-cargo/8514)
- [https://gitlab.kitware.com/cmake/cmake/-/issues/25492](https://gitlab.kitware.com/cmake/cmake/-/issues/25492)
