qt_build_utils/installation/
mod.rs

1// SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
2// SPDX-FileContributor: Andrew Hayzen <andrew.hayzen@kdab.com>
3//
4// SPDX-License-Identifier: MIT OR Apache-2.0
5
6#[cfg(feature = "qmake")]
7pub(crate) mod qmake;
8
9use semver::Version;
10use std::path::PathBuf;
11
12use crate::QtTool;
13
14/// A Qt Installation that can be used by cxx-qt-build to run Qt related tasks
15///
16/// Note that it is the responsbility of the QtInstallation implementation
17/// to print any cargo::rerun-if-changed lines
18pub trait QtInstallation {
19    /// Return the framework paths for Qt
20    ///
21    /// This is intended to be passed to whichever tool you are using to invoke the C++ compiler.
22    fn framework_paths(&self, qt_modules: &[String]) -> Vec<PathBuf>;
23    /// Return the include paths for Qt, including Qt module subdirectories.
24    ///
25    /// This is intended to be passed to whichever tool you are using to invoke the C++ compiler.
26    fn include_paths(&self, qt_modules: &[String]) -> Vec<PathBuf>;
27    /// Configure the given cc::Build and cargo to link to the given Qt modules
28    ///
29    // TODO: should we hand in a cc::Build or should we instead return a struct
30    // with details of the rustc-link-lib / search paths ? and then have the
31    // calling function apply those and any flags to the cc::Build?
32    // eg return the following?
33    //
34    // pub struct LinkArgs {
35    //     builder_flag_if_supported: Vec<String>,
36    //     builder_object: Vec<String>,
37    //     rustc_link_arg: Vec<String>,
38    //     rustc_link_lib: Vec<String>,
39    //     rustc_link_search: Vec<String>,
40    // }
41    fn link_modules(&self, builder: &mut cc::Build, qt_modules: &[String]);
42    /// Find the path to a given Qt tool for the Qt installation
43    fn try_find_tool(&self, tool: QtTool) -> anyhow::Result<PathBuf>;
44    /// Version of the detected Qt installation
45    fn version(&self) -> Version;
46}