mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-07-30 17:36:08 +08:00
Each Rust source file given to a target is considered a separate crate root. There's a concept of a "main crate root", which is the `.rs` file that is given to the final linker phase in CMake. Other Rust source file in a target are built as rlib separately. The project can still build `.rs` files into object files by setting the Rust_EMIT property on the desired source file.
11 lines
456 B
CMake
11 lines
456 B
CMake
set(CMAKE_Rust_COMPILER "@CMAKE_Rust_COMPILER@")
|
|
set(CMAKE_Rust_COMPILER_ENV_VAR "RUSTC")
|
|
set(CMAKE_Rust_SOURCE_FILE_EXTENSIONS rs)
|
|
set(CMAKE_Rust_COMPILER_LOADED 1)
|
|
set(CMAKE_Rust_COMPILER_WORKS @CMAKE_Rust_COMPILER_WORKS@)
|
|
|
|
# Make sure CMake prefers to link with Rust when Rust source files are present
|
|
set(CMAKE_Rust_LINKER_PREFERENCE 60)
|
|
# Once compiled by Rust, static libraries can be linked by anyone.
|
|
set(CMAKE_Rust_LINKER_PREFERENCE_PROPAGATES 0)
|