Skip to content

Commit 16f49b9

Browse files
ahayzen-kdabLeonMatthesKDAB
authored andcommitted
cxx-qt-build: pass in qml modules to opts
This then means we can remove the gui and qml features
1 parent 1339314 commit 16f49b9

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737

3838
- Missing include for `MaybeLockGuard` when using only `extern "C++Qt"` signals
3939

40+
### Removed
41+
42+
- `qt_gui` and `qt_qml` features from `cxx-qt-build` they are only used in `cxx-qt-lib(-headers)` now
43+
4044
## [0.6.0](https://github.com/KDAB/cxx-qt/compare/v0.5.3...v0.6.0) - 2023-11-17
4145

4246
### Added

crates/cxx-qt-build/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ codespan-reporting = "0.11"
2424
version_check = "0.9"
2525

2626
[features]
27-
default = ["qt_gui", "qt_qml"]
28-
qt_gui = []
29-
qt_qml = []
3027
link_qt_object_files = ["qt-build-utils/link_qt_object_files"]

crates/cxx-qt-build/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,15 @@ pub struct CxxQtBuildersOpts {
315315
pub defines: HashSet<String>,
316316
/// Contents, directory, file name
317317
pub headers: Vec<(String, String, String)>,
318+
/// Qt modules that are required
319+
pub qt_modules: HashSet<String>,
318320
}
319321

320322
impl CxxQtBuilder {
321323
/// Create a new builder
322324
pub fn new() -> Self {
323325
let mut qt_modules = HashSet::new();
324326
qt_modules.insert("Core".to_owned());
325-
#[cfg(feature = "qt_gui")]
326-
qt_modules.insert("Gui".to_owned());
327-
#[cfg(feature = "qt_qml")]
328-
qt_modules.insert("Qml".to_owned());
329327
Self {
330328
rust_sources: vec![],
331329
qobject_headers: vec![],
@@ -374,7 +372,7 @@ impl CxxQtBuilder {
374372

375373
/// Link additional [Qt modules](https://doc.qt.io/qt-6/qtmodules.html).
376374
/// Specify their names without the `Qt` prefix, for example `"Widgets"`.
377-
/// The Core and any feature enabled modules are linked automatically; there is no need to specify them.
375+
/// The `Core` module and any modules from [CxxQtBuildersOpts] are linked automatically; there is no need to specify them.
378376
pub fn qt_module(mut self, module: &str) -> Self {
379377
self.qt_modules.insert(module.to_owned());
380378
self
@@ -471,6 +469,9 @@ impl CxxQtBuilder {
471469
// Add any of the defines
472470
self.extra_defines.extend(opts.defines);
473471

472+
// Add any of the Qt modules
473+
self.qt_modules.extend(opts.qt_modules);
474+
474475
self
475476
}
476477

crates/cxx-qt-lib-headers/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ repository.workspace = true
1313

1414
[features]
1515
default = []
16-
qt_gui = ["cxx-qt-build/qt_gui"]
17-
qt_qml = ["cxx-qt-build/qt_qml"]
16+
qt_gui = []
17+
qt_qml = []
1818

1919
[dependencies]
2020
cxx-qt-build.workspace = true

crates/cxx-qt-lib-headers/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,16 @@ pub fn build_opts() -> cxx_qt_build::CxxQtBuildersOpts {
108108
}
109109

110110
#[cfg(feature = "qt_gui")]
111-
opts.defines.insert("CXX_QT_GUI_FEATURE".to_owned());
111+
{
112+
opts.defines.insert("CXX_QT_GUI_FEATURE".to_owned());
113+
opts.qt_modules.insert("Gui".to_owned());
114+
}
115+
112116
#[cfg(feature = "qt_qml")]
113-
opts.defines.insert("CXX_QT_QML_FEATURE".to_owned());
117+
{
118+
opts.defines.insert("CXX_QT_QML_FEATURE".to_owned());
119+
opts.qt_modules.insert("Qml".to_owned());
120+
}
114121

115122
opts
116123
}

0 commit comments

Comments
 (0)