blob: c7df9a8f5fc6fed2574603e78610b4204cc72d6c (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
fn main() {
compile();
}
#[cfg(target_os = "linux")]
fn compile() {
let mut build = cc::Build::new();
build.cpp(true);
build.flag("-std=c++11");
build.file("cpp/qt_capi.cpp").include("cpp");
let lib = pkg_config::find_library("Qt5Gui").expect("Unable to find Qt5Gui");
for path in lib.include_paths {
build.include(path.to_str().expect("Failed to convert include path to str"));
}
build.compile("libqtc.a");
}
#[cfg(target_os = "windows")]
fn compile() {
use std::env;
use std::path::Path;
let qt_dir = env::var("QT_DIR").expect("QT_DIR is not set");
let qt_path = Path::new(&qt_dir);
let mut build = cc::Build::new();
let tool = build.get_compiler();
build.cpp(true);
build.file("cpp/qt_capi.cpp").include("cpp");
build.include(qt_path.join("include"));
build.include(qt_path.join("include").join("QtCore"));
build.include(qt_path.join("include").join("QtGui"));
if tool.is_like_msvc() {
build.compile("libqtc.lib");
} else {
build.flag("-std=c++11");
build.compile("libqtc.a");
}
println!("cargo:rustc-link-search={}", qt_path.join("bin").to_str().unwrap()); // for MinGW
println!("cargo:rustc-link-search={}", qt_path.join("lib").to_str().unwrap()); // for MSVC
println!("cargo:rustc-link-lib=Qt5Core");
println!("cargo:rustc-link-lib=Qt5Gui");
}
#[cfg(target_os = "macos")]
fn compile() {
use std::env;
use std::path::Path;
let qt_dir = env::var("QT_DIR").expect("QT_DIR is not set");
let qt_path = Path::new(&qt_dir);
let mut build = cc::Build::new();
build.cpp(true);
build.flag("-std=c++11");
build.flag(&format!("-F{}/lib", qt_dir));
build.file("cpp/qt_capi.cpp").include("cpp");
build.include(qt_path.join("lib/QtGui.framework/Headers"));
build.include(qt_path.join("lib/QtCore.framework/Headers"));
build.compile("libqtc.a");
println!("cargo:rustc-link-search=framework={}/lib", qt_dir);
println!("cargo:rustc-link-lib=framework=QtCore");
println!("cargo:rustc-link-lib=framework=QtGui");
}
|