-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
22 lines (20 loc) · 1.04 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
use std::env;
fn main() {
// directly look for env variable CUDA_LIB_PATH which specifies the CUDA library path
let cuda_lib_path = match env::var("CUDA_LIB_PATH") {
Ok(path) => path,
Err(_) => {
// CUDA_LIB_PATH not set, provide instructions
println!("cargo:warning=CUDA_LIB_PATH env variable not set");
println!("cargo:warning=Please set CUDA_LIB_PATH to your CUDA library install path");
println!("cargo:warning=For example on Linux: export CUDA_LIB_PATH=/usr/local/cuda/lib64");
std::process::exit(1);
}
};
// if CUDA_LIB_PATH is found, proceed to instruct cargo to link against CUDA libraries
println!("cargo:rustc-link-search=native={}", cuda_lib_path);
println!("cargo:rustc-link-lib=cuda"); // CUDA driver library
println!("cargo:rustc-link-lib=cudart"); // CUDA runtime library for simple management
println!("cargo:rustc-link-lib=nvrtc"); // NVRTC library for kernel compilation
// more libraries to link?
}