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

figure out and document how to link multiple cxx-qt modules into an application #148

Open
Be-ing opened this issue Jun 28, 2022 · 4 comments
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ upstream blocked on an upstream issue

Comments

@Be-ing
Copy link
Contributor

Be-ing commented Jun 28, 2022

Application developers will likely want to link multiple cxx-qt modules into applications. I can think of two approaches this could take:

  1. Create a cargo workspace within the application repository with multiple lib crates, built as normal rlib crates. Link them together into one staticlib crate and link the staticlib crate into the C++ application. This is the approach Firefox takes: https://hg.mozilla.org/mozilla-central/rev/841c2247f57d, https://bugzilla.mozilla.org/show_bug.cgi?id=1163224
  2. Write one big staticlib crate with separate modules using cxx-qt within it. I doubt this would be a good idea for build times because Cargo parallelizes at the level of crates, not modules.
@Be-ing Be-ing changed the title figure out and document how to link multiple cxx-qt libraries into an application figure out and document how to link multiple cxx-qt modules into an application Jun 28, 2022
@Be-ing
Copy link
Contributor Author

Be-ing commented Jun 28, 2022

Related: #119

@ahayzen-kdab
Copy link
Collaborator

I assume you mean multiple crates ? And not multiple modules, as we support already defining multiple modules that are in the same crate and are then expose multiple QObject's to C++.

Are you describing having multiple Rust crates so that there would be two Rust static libraries to link to the C++ application ? As I don't really see why that wouldn't work already ? (or would there be collisions where some CXX things are the same in both the libs?) Once we have the CMake CLI tool it'll be easier to work with cargo workspaces too.

@Be-ing
Copy link
Contributor Author

Be-ing commented Jun 28, 2023

Create a cargo workspace within the application repository with multiple lib crates, built as normal rlib crates. Link them together into one staticlib crate and link the staticlib crate into the C++ application. This is the approach Firefox takes: https://hg.mozilla.org/mozilla-central/rev/841c2247f57d, https://bugzilla.mozilla.org/show_bug.cgi?id=1163224

Proof of concept of that is in #598. Unfortunately it is blocked on rust-lang/rust#108081 upstream.

@Be-ing Be-ing added 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ upstream blocked on an upstream issue labels Jul 7, 2023
@LeonMatthesKDAB
Copy link
Collaborator

This may be done now? We should double-check for 0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo ⬆️ upstream blocked on an upstream issue
Projects
None yet
Development

No branches or pull requests

3 participants