use cc::Build;
use std::env;
use std::path::Path;
pub fn cl_cpp_openmp() -> Build {
let mut builder = Build::new();
println!("cargo:rerun-if-env-changed=CC");
if cfg!(target_os = "macos") {
if !env::var("CC").is_ok() {
if Path::new("/opt/homebrew/opt/llvm/bin/clang").exists() {
builder.compiler("/opt/homebrew/opt/llvm/bin/clang");
println!("cargo:rustc-link-search=/opt/homebrew/opt/llvm/lib");
println!("cargo:rustc-link-search=/opt/homebrew/lib");
}
}
println!("cargo:rustc-link-lib=dylib=omp");
}
else {
println!("cargo:rustc-link-lib=dylib=gomp");
}
builder
.cpp(true)
.flag("-Wall")
.flag("-fopenmp");
builder
}
pub fn cl_cuda(archs: Option<&[u32]>) -> Build {
let mut builder_cuda = Build::new();
builder_cuda
.cuda(true)
.flag("-Xcompiler").flag("-Wall");
for arch in archs.unwrap_or(&[86, 75, 61]) {
builder_cuda.flag("-gencode")
.flag(&format!("arch=compute_{arch},code=sm_{arch}"));
}
builder_cuda
}