summaryrefslogtreecommitdiff
path: root/crates/flasher-qt/build.rs
blob: e4bdfc2044fc78d1010ccfe46526ffe7397943c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
fn main() {
    println!("cargo:rerun-if-changed=src/ui.cpp");

    let qt = pkg_config::Config::new()
        .atleast_version("5.12")
        .cargo_metadata(false)
        .probe("Qt5Widgets")
        .expect("Qt 5 Widgets development files were not found (install qt5-base-devel)");

    let mut build = cc::Build::new();
    build.cpp(true).file("src/ui.cpp").flag_if_supported("-std=c++17");
    for path in &qt.include_paths {
        build.include(path);
    }
    build.compile("flasher_qt_ui");

    // Keep shared Qt libraries after our static C++ archive on the linker
    // command line; GNU ld resolves static archives from left to right.
    for path in &qt.link_paths {
        println!("cargo:rustc-link-search=native={}", path.display());
    }
    println!("cargo:rustc-link-lib=Qt5Widgets");
    println!("cargo:rustc-link-lib=Qt5Gui");
    println!("cargo:rustc-link-lib=Qt5Core");
}