-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathbuild.rs
56 lines (45 loc) · 1.51 KB
/
build.rs
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
use cmake::Config;
fn main() {
let mut cmake_config = Config::new(".");
cmake_config
.profile("Release")
.define("BUILD_TESTING", "OFF");
cmake_config.define("BUILD_SHARED_LIBS", "OFF");
if cfg!(target_os = "windows") {
cmake_config
.generator("Visual Studio 17 2022")
.cxxflag("/EHsc");
}
let cmake_dest = cmake_config.build();
let mut bridge_build = cxx_build::bridge("src/lib.rs");
bridge_build
.file("src/RustFFI.cpp")
.include("src")
.include(format!("{}/include", cmake_dest.display()))
.include(format!("{}/include/eigen3", cmake_dest.display()))
.std("c++20");
if cfg!(target_os = "windows") {
bridge_build.flag("/EHsc").flag("/utf-8");
}
bridge_build.compile("TrajoptLibRust");
println!(
"cargo:rustc-link-search=native={}/bin",
cmake_dest.display()
);
println!(
"cargo:rustc-link-search=native={}/lib",
cmake_dest.display()
);
println!(
"cargo:rustc-link-search=native={}/build/_deps/sleipnir-build/",
cmake_dest.display()
);
println!("cargo:rustc-link-lib=TrajoptLibRust");
println!("cargo:rustc-link-lib=TrajoptLib");
println!("cargo:rustc-link-lib=Sleipnir");
println!("cargo:rustc-link-lib=fmt");
println!("cargo:rerun-if-changed=CMakeLists.txt");
println!("cargo:rerun-if-changed=cmake");
println!("cargo:rerun-if-changed=include");
println!("cargo:rerun-if-changed=src");
}