micahsnyder / cmake-rust-demo Goto Github PK
View Code? Open in Web Editor NEWA project that demonstrates building a C application with CMake that has Rust static library components
License: MIT License
A project that demonstrates building a C application with CMake that has Rust static library components
License: MIT License
There is a non-insignificant % of build environments that will need source tarballs that can compile without requiring the internet.
It should be possible to run cargo vendor
for each crate in a CMake project when using the CPack Archive Generator so that release tarballs do not require internet access to build.
This functionality should be built-into the Rust.cmake module, or otherwise somehow demonstrated in this project.
It would be good to test cross compiling.
On Linux compiling for different architectures and on Windows compiling for x86 or perhaps even ARM.
The current unit tests for the Rust libs are just template stuff from cargo new
. it would be nice to have meaningful tests.
At present this demo only builds static libs from Rust crates for use in C/C++ projects. It seems reasonable that someone would want to replace their C/C++ executables with Rust executables while still building a mixed C/C++ & Rust shared library.
Eg: for the clamav project, we may wish to replace SigTool or ClamSubmit, which are fairly trivial programs, with Rust executables that still depend on libclamav. This does get a whole lot more complicated because then the Rust interface to the C shared lib must be present. For ClamAV, would that mean integrating something like clamav-sys
& clamav-rs
into the main ClamAV repository? Or is the best solution then to migrate SigTool and such out entirely into their own repositories (perhaps not ideal)?
This question requires some investigation.
Currently the only way I know of to add the native static libs to the linker dependencies in CMake it to do it at configure-time. This means we haven't yet compiled the Rust crates and don't know what their real dependencies are, we can only compile an "empty" program to see what the very basic dependencies will be.
As a consequence, bringing in native static lib dependencies in Rust will break the build unless you manually link them in CMake. See 4bf9dfb for an example.
Ideally we should determine the native static libs just after compiling the crates and dynamically add them to the CMake target dependencies at that time, propagating them to any downstream targets. I don't know if CMake is actually capable of this though. ๐คทโโ๏ธ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.