diff --git a/Cargo.toml b/Cargo.toml index 5f1e497..d7133bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,6 @@ rand = "0.8.5" git_info = "^0.1.2" rayon = "1.5.3" toml = "0.8.19" + +[build-dependencies] +num_cpus = "1.16.0" \ No newline at end of file diff --git a/build.rs b/build.rs index 9b94e24..0907077 100644 --- a/build.rs +++ b/build.rs @@ -4,15 +4,17 @@ use std::env; use std::process::Command; +use num_cpus; fn main() { let out_dir = env::var("OUT_DIR").unwrap(); + let num_threads = num_cpus::get(); println!("cargo:rerun-if-changed=src/cpp"); println!("cargo:rerun-if-changed=eigsys/eig-hpp"); let output = Command::new("make") .current_dir("src/cpp") .arg(format!("OUT_DIR={}", out_dir)) - .arg("-j12") + .arg(format!("-j{}", num_threads)) .output() .expect("Failed to execute make command");