Rust_EMIT — CMake 4.4.2 Documentation

# Rust_EMIT

Added in version 4.4.

Note

Experimental. Gated by `CMAKE_EXPERIMENTAL_RUST`.

This property controls the type of output generated by the Rust compiler. Can be one of several values:

`link`

  This is the default if the property is not set. The crate will be compiled into an rlib file, e.g.: `libfile.rs.rlib`

  Note

  CMake will automatically prefix the generated `rlib` file with `lib` as the Rust compiler always requires such a prefix for external crates.

`obj`

  Generate a native object file, e.g.: `file.rs.o`

`asm`

  Generate an assembly file, e.g.: `file.rs.s`

Note

The `obj` and `asm` output types are known to have the following limitations:

- When enabled, the Rust compiler disables multiple codegen units and ThinLTO. Depending on the situation, this can affect the generated code, optimizations. It also reduce the internal parallelism inside and the compiler and can reduce the effectiveness of incremental rebuilds.

- The generated `obj` files cannot be used as external crates, so other Rust code can only use C-style API from them.

- The generated `obj` files cannot be linked as-is with native linkers, additional crates from the Rust toolchain needs to linked too. The actual crates to link depend on the code and compiler options.