use cmake::Config;
fn main() {
let mut cfg = &mut Config::new("c_src/mimalloc");
cfg = cfg.define("MI_OVERRIDE", "OFF");
if cfg!(feature = "secure") {
cfg = cfg.define("MI_SECURE", "OFF");
}
if cfg!(all(windows, target_env = "msvc")) {
if cfg!(debug_assertions) {
cfg = cfg.cflag("/DWIN32 /D_WINDOWS /W3 /MDd /Zi /Ob0 /Od /RTC1");
} else {
cfg = cfg.cflag("/DWIN32 /D_WINDOWS /W3 /MD /O2 /Ob2 /DNDEBUG");
}
}
let (out_dir, out_name) = if cfg!(all(windows, target_env = "msvc")) {
if cfg!(debug_assertions) {
("./build/Debug", "mimalloc-static-debug")
} else {
("./build/Release", "mimalloc-static")
}
} else {
if cfg!(debug_assertions) {
("./build", "mimalloc-debug")
} else {
("./build", "mimalloc")
}
};
let mut dst = cfg.build_target("mimalloc-static").build();
dst.push(out_dir);
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib={}", out_name);
}