Skip to content

An example of how to use the CMake crate in conjunction with rust-bindgen for integrating vendored C/C++ libraries with rust

Notifications You must be signed in to change notification settings

paigeadelethompson/rust_bindgen_and_nested_cmake_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Preface

I needed to create this to prove to myself that it is possible (it is) so if this helps then I'm glad. As you might expect, a library wraps a bindings library which contains the C/C++/CMake project:

.
β”œβ”€β”€ Cargo.lock
β”œβ”€β”€ Cargo.toml
β”œβ”€β”€ hello_lib
β”‚Β Β  β”œβ”€β”€ Cargo.lock
β”‚Β Β  β”œβ”€β”€ Cargo.toml
β”‚Β Β  β”œβ”€β”€ libhello_bindings
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Cargo.lock
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ Cargo.toml
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ build.rs
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ libhello
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ CMakeLists.txt
β”‚Β Β  β”‚Β Β  β”‚Β Β  β”œβ”€β”€ hello.c
β”‚Β Β  β”‚Β Β  β”‚Β Β  └── proto.h
β”‚Β Β  β”‚Β Β  └── src
β”‚Β Β  β”‚Β Β      └── lib.rs
β”‚Β Β  └── src
β”‚Β Β      └── lib.rs
└── src
    └── main.rs

the file build.rs is responsible for first executing the CMake build as well as generating the Rust FFI bindings which are used (and tested with cargo test) in the hello_lib sub-crate.

Info

About

An example of how to use the CMake crate in conjunction with rust-bindgen for integrating vendored C/C++ libraries with rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published