@@ -168,7 +168,7 @@ impl Library {
168
168
let mut library_dir = None ;
169
169
let mut include_dir = None ;
170
170
let mut iomp5_dir = None ;
171
- for path in walkdir:: WalkDir :: new ( root_dir)
171
+ for ( dir , file_name ) in walkdir:: WalkDir :: new ( root_dir)
172
172
. into_iter ( )
173
173
. flatten ( ) // skip unreadable directories
174
174
. flat_map ( |entry| {
@@ -190,59 +190,56 @@ impl Library {
190
190
} ) {
191
191
return None ;
192
192
}
193
- Some ( path)
194
- } )
195
- {
196
- let dir = path
197
- . parent ( )
198
- . expect ( "parent must exist here since this is under `root_dir`" )
199
- . to_owned ( ) ;
200
193
201
- let ( stem, ext) = match ( path. file_stem ( ) , path. extension ( ) ) {
202
- ( Some ( stem) , Some ( ext) ) => (
203
- stem. to_str ( ) . context ( "Non UTF8 filename" ) ?,
204
- ext. to_str ( ) . context ( "Non UTF8 filename" ) ?,
205
- ) ,
206
- _ => continue ,
207
- } ;
194
+ let dir = path
195
+ . parent ( )
196
+ . expect ( "parent must exist here since this is under `root_dir`" )
197
+ . to_owned ( ) ;
208
198
209
- if stem == "mkl" && ext == "h" {
210
- log:: info!( "Found mkl.h: {}" , path. display( ) ) ;
199
+ if let Some ( Some ( file_name) ) = path. file_name ( ) . map ( |f| f. to_str ( ) ) {
200
+ Some ( ( dir, file_name. to_string ( ) ) )
201
+ } else {
202
+ None
203
+ }
204
+ } )
205
+ {
206
+ if include_dir. is_none ( ) && file_name == "mkl.h" {
207
+ log:: info!( "Found mkl.h at {}" , dir. display( ) ) ;
211
208
include_dir = Some ( dir) ;
212
209
continue ;
213
210
}
214
211
215
- let name = if let Some ( name) = stem. strip_prefix ( std:: env:: consts:: DLL_PREFIX ) {
216
- name
217
- } else {
218
- continue ;
219
- } ;
220
-
221
- match name {
222
- "mkl_core" => {
223
- match ( config. link , ext) {
224
- ( LinkType :: Static , STATIC_EXTENSION )
225
- | ( LinkType :: Dynamic , std:: env:: consts:: DLL_EXTENSION ) => { }
226
- _ => continue ,
212
+ if library_dir. is_none ( ) {
213
+ for name in mkl_libs ( config) {
214
+ if file_name == as_filename ( config. link , & name) {
215
+ log:: info!( "Found {} at {}" , file_name, dir. display( ) ) ;
216
+ library_dir = Some ( dir. clone ( ) ) ;
217
+ continue ;
227
218
}
228
- log:: info!( "Found: {}" , path. display( ) ) ;
229
- library_dir = Some ( dir) ;
230
219
}
231
- "iomp5" => {
232
- // Allow both dynamic/static library by default
233
- //
234
- // This is due to some distribution does not provide libiomp5.a
235
- if cfg ! ( feature = "openmp-strict-link-type" ) {
236
- match ( config. link , ext) {
237
- ( LinkType :: Static , STATIC_EXTENSION )
238
- | ( LinkType :: Dynamic , std:: env:: consts:: DLL_EXTENSION ) => { }
239
- _ => continue ,
220
+ }
221
+
222
+ if file_name. starts_with ( OPENMP_RUNTIME_LIB ) {
223
+ // Allow both dynamic/static library by default
224
+ //
225
+ // This is due to some distribution does not provide libiomp5.a
226
+ if cfg ! ( feature = "openmp-strict-link-type" ) {
227
+ let ext = match config. link {
228
+ LinkType :: Static => {
229
+ if cfg ! ( any( target_os = "linux" , target_os = "macos" ) ) {
230
+ "a"
231
+ } else {
232
+ "lib"
233
+ }
240
234
}
235
+ LinkType :: Dynamic => std:: env:: consts:: DLL_EXTENSION ,
236
+ } ;
237
+ if !file_name. ends_with ( ext) {
238
+ continue ;
241
239
}
242
- log:: info!( "Found: {}" , path. display( ) ) ;
243
- iomp5_dir = Some ( dir) ;
244
240
}
245
- _ => { }
241
+ log:: info!( "Found OpenMP runtime ({}): {}" , file_name, dir. display( ) ) ;
242
+ iomp5_dir = Some ( dir) ;
246
243
}
247
244
}
248
245
if config. parallel == Threading :: OpenMP && iomp5_dir. is_none ( ) {
0 commit comments