@@ -109,20 +109,6 @@ fn main() {
109109 ) ;
110110 }
111111
112- // Link against nvcomp dynamically.
113- println ! ( "cargo:rustc-link-search=native={}" , lib_dir. display( ) ) ;
114- println ! ( "cargo:rustc-link-lib=dylib=nvcomp" ) ;
115- println ! ( "cargo:rustc-link-arg=-Wl,-rpath,{}" , lib_dir. display( ) ) ;
116-
117- // Export the library path for downstream crates via the `links` manifest key.
118- // Downstream crates can access this via `env::var("DEP_NVCOMP_LIB_DIR")` in their
119- // build.rs and add their own rpath:
120- //
121- // if let Ok(nvcomp_lib) = env::var("DEP_NVCOMP_LIB_DIR") {
122- // println!("cargo:rustc-link-arg=-Wl,-rpath,{nvcomp_lib}");
123- // }
124- println ! ( "cargo:lib_dir={}" , lib_dir. display( ) ) ;
125-
126112 let bindings = bindgen:: Builder :: default ( )
127113 . header ( include_dir. join ( "nvcomp.h" ) . to_string_lossy ( ) )
128114 . header ( include_dir. join ( "nvcomp/zstd.h" ) . to_string_lossy ( ) )
@@ -142,6 +128,19 @@ fn main() {
142128 // Set cuda_available cfg if CUDA is detected on the system.
143129 // Gates tests and benchmarks that require CUDA at runtime.
144130 if cuda_available ( ) {
131+ // Link against nvcomp dynamically.
132+ println ! ( "cargo:rustc-link-search=native={}" , lib_dir. display( ) ) ;
133+ println ! ( "cargo:rustc-link-lib=dylib=nvcomp" ) ;
134+ println ! ( "cargo:rustc-link-arg=-Wl,-rpath,{}" , lib_dir. display( ) ) ;
135+
136+ // Export the library path for downstream crates via the `links` manifest key.
137+ // Downstream crates can access this via `env::var("DEP_NVCOMP_LIB_DIR")` in their
138+ // build.rs and add their own rpath:
139+ //
140+ // if let Ok(nvcomp_lib) = env::var("DEP_NVCOMP_LIB_DIR") {
141+ // println!("cargo:rustc-link-arg=-Wl,-rpath,{nvcomp_lib}");
142+ // }
143+ println ! ( "cargo:lib_dir={}" , lib_dir. display( ) ) ;
145144 println ! ( "cargo:rustc-cfg=cuda_available" ) ;
146145 }
147146}
0 commit comments