Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with CMake project that uses cargo #189

Open
mschuckmann opened this issue Aug 15, 2024 · 2 comments
Open

Working with CMake project that uses cargo #189

mschuckmann opened this issue Aug 15, 2024 · 2 comments

Comments

@mschuckmann
Copy link

I'm working on creating a recipe that builds a C interop library for a rust based project zenoh-c.

The recommended method for building and installing the library is to use CMake which uses cargo to build the .so file and then uses standard CMake idioms to install the library, headers, pkgconfig, and CMake configuration files.

It seems that I can use cargo_bin to build the .so file without much problem but I'm at a bit of a loss on how to make the CMake specific stuff work. I also tried using snippets of code from cargo_bin.bbclass in my recipe to configure the environment to allow CMake to drive the cargo build for the target but it's not quite working like I'd expect.

I'm wondering if anyone can make any recommendations the best way to go here.

I'm also wondering if maybe the code in cargo_bin.bbclass that configures the environment, scripts, etc can be broken out into a separate class that recipes that don't want to call cargo build directly can use. The cargo_bin.bbclass would obviously use this new class.

@tronical
Copy link

In Slint we build a cdylib with cargo (via Corrosion) and package it up with CMake. It’s quite okay to combine both classes, we do that at https://github.com/slint-ui/meta-slint/blob/meta-rust-bin/recipes-slint/slint/slint-cpp-v2.inc

@mschuckmann
Copy link
Author

That looks promising, thank you for the example @tronical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants