GithubHelp home page GithubHelp logo

micahsnyder / cmake-rust-demo Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 1.0 53 KB

A project that demonstrates building a C application with CMake that has Rust static library components

License: MIT License

CMake 51.51% C 3.78% Rust 43.27% Shell 1.43%

cmake-rust-demo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cmake-rust-demo's Issues

cargo vendor + CPack Archive Generator

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.

Cross compile tests

It would be good to test cross compiling.

On Linux compiling for different architectures and on Windows compiling for x86 or perhaps even ARM.

Meaningful unit tests

The current unit tests for the Rust libs are just template stuff from cargo new. it would be nice to have meaningful tests.

Building Rust binaries in CMake project(?)

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.

Native static lib detection misses "Extra" libs, like winsock.

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. ๐Ÿคทโ€โ™‚๏ธ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.