@@ -7,8 +7,13 @@ use std::{
7
7
8
8
pub fn include_cuda ( ) {
9
9
if env:: var ( "DOCS_RS" ) . is_err ( ) && !cfg ! ( doc) {
10
- let cuda_lib_dir = find_cuda_lib_dir ( ) . expect ( "Could not find a cuda installation" ) ;
11
- println ! ( "cargo:rustc-link-search=native={}" , cuda_lib_dir. display( ) ) ;
10
+ let paths = find_cuda_lib_dirs ( ) ;
11
+ if paths. is_empty ( ) {
12
+ panic ! ( "Could not find a cuda installation" ) ;
13
+ }
14
+ for path in paths {
15
+ println ! ( "cargo:rustc-link-search=native={}" , path. display( ) ) ;
16
+ }
12
17
13
18
println ! ( "cargo:rustc-link-lib=dylib=cuda" ) ;
14
19
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
@@ -51,7 +56,7 @@ pub fn find_cuda_root() -> Option<PathBuf> {
51
56
}
52
57
53
58
#[ cfg( target_os = "windows" ) ]
54
- pub fn find_cuda_lib_dir ( ) -> Option < PathBuf > {
59
+ pub fn find_cuda_lib_dirs ( ) -> Vec < PathBuf > {
55
60
if let Some ( root_path) = find_cuda_root ( ) {
56
61
// To do this the right way, we check to see which target we're building for.
57
62
let target = env:: var ( "TARGET" )
@@ -93,28 +98,21 @@ pub fn find_cuda_lib_dir() -> Option<PathBuf> {
93
98
let lib_dir = root_path. join ( "lib" ) . join ( lib_path) ;
94
99
95
100
return if lib_dir. is_dir ( ) {
96
- Some ( lib_dir)
101
+ vec ! [ lib_dir]
97
102
} else {
98
- None
103
+ vec ! [ ]
99
104
} ;
100
105
}
101
106
102
- None
107
+ vec ! [ ]
103
108
}
104
109
105
110
#[ cfg( not( target_os = "windows" ) ) ]
106
- pub fn find_cuda_lib_dir ( ) -> Option < PathBuf > {
111
+ pub fn find_cuda_lib_dirs ( ) -> Vec < PathBuf > {
107
112
if let Some ( root_path) = find_cuda_root ( ) {
108
- let lib_dir = root_path. join ( "lib64" ) ;
109
- // TODO (AL): we probably want to check for an actual library under here
110
- // too...
111
- if lib_dir. is_dir ( ) {
112
- Some ( lib_dir)
113
- } else {
114
- None
115
- }
113
+ vec ! [ root_path. clone( ) . join( "lib64" ) , root_path. join( "lib" ) ]
116
114
} else {
117
- None
115
+ vec ! [ ]
118
116
}
119
117
}
120
118
0 commit comments