mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03: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.
31 lines
592 B
Rust
31 lines
592 B
Rust
extern "C" {
|
|
// Functions defined in C
|
|
fn c_obj_greet();
|
|
fn c_static_greet();
|
|
fn c_shared_greet();
|
|
|
|
// Functions defined in C++
|
|
fn cpp_shared_greet();
|
|
|
|
// Functions defined in Rust through a C-style ABI
|
|
fn rs_staticlib_greet();
|
|
fn rs_cdylib_greet();
|
|
}
|
|
|
|
// Functions defined in Rust, using native Rust ABI
|
|
extern crate rs_rlib;
|
|
use rs_rlib::rs_rlib_greet;
|
|
|
|
fn main() {
|
|
println!("Hello from main.rs");
|
|
unsafe {
|
|
c_obj_greet();
|
|
c_static_greet();
|
|
c_shared_greet();
|
|
cpp_shared_greet();
|
|
rs_staticlib_greet();
|
|
rs_cdylib_greet();
|
|
}
|
|
rs_rlib_greet();
|
|
}
|