@@ -29,7 +29,7 @@ impl Version {
29
29
}
30
30
31
31
pub fn parse ( s : & str ) -> Option < Self > {
32
- let re = Regex :: new ( r"^(1)\.(8|10|12|13)\.(\d\d?)(_\d+)?(-patch\d+)?$" ) . ok ( ) ?;
32
+ let re = Regex :: new ( r"^(1)\.(8|10|12|13|14 )\.(\d\d?)(_\d+)?(-patch\d+)?$" ) . ok ( ) ?;
33
33
let captures = re. captures ( s) ?;
34
34
Some ( Self {
35
35
major : captures. get ( 1 ) . and_then ( |c| c. as_str ( ) . parse :: < u8 > ( ) . ok ( ) ) ?,
@@ -73,6 +73,13 @@ fn is_root_dir<P: AsRef<Path>>(path: P) -> bool {
73
73
is_inc_dir ( path. as_ref ( ) . join ( "include" ) )
74
74
}
75
75
76
+ #[ allow( dead_code) ]
77
+ fn is_msvc ( ) -> bool {
78
+ // `cfg!(target = "msvc")` will report wrong value when using
79
+ // MSVC toolchain targeting GNU.
80
+ std:: env:: var ( "CARGO_CFG_TARGET_ENV" ) . unwrap ( ) == "msvc"
81
+ }
82
+
76
83
#[ derive( Clone , Debug ) ]
77
84
struct RuntimeError ( String ) ;
78
85
@@ -115,7 +122,7 @@ fn get_runtime_version_single<P: AsRef<Path>>(path: P) -> Result<Version, Box<dy
115
122
116
123
fn validate_runtime_version ( config : & Config ) {
117
124
println ! ( "Looking for HDF5 library binary..." ) ;
118
- let libfiles = & [ "libhdf5.dylib" , "libhdf5.so" , "hdf5.dll" ] ;
125
+ let libfiles = & [ "libhdf5.dylib" , "libhdf5.so" , "hdf5.dll" , "libhdf5-0.dll" ] ;
119
126
let mut link_paths = config. link_paths . clone ( ) ;
120
127
if cfg ! ( all( unix, not( target_os = "macos" ) ) ) {
121
128
if let Some ( ldv) = run_command ( "ld" , & [ "--verbose" ] ) {
@@ -451,7 +458,7 @@ mod windows {
451
458
452
459
pub fn find_hdf5_via_winreg ( config : & mut LibrarySearcher ) {
453
460
// Official HDF5 binaries on Windows are built for MSVC toolchain only.
454
- if config. inc_dir . is_some ( ) || !cfg ! ( target_env = "msvc" ) {
461
+ if config. inc_dir . is_some ( ) || !is_msvc ( ) {
455
462
return ;
456
463
}
457
464
// Check the list of installed programs, see if there's HDF5 anywhere;
@@ -492,7 +499,7 @@ impl LibrarySearcher {
492
499
config. user_provided_dir = true ;
493
500
config. inc_dir = Some ( root. join ( "include" ) ) ;
494
501
}
495
- if cfg ! ( target_env = "msvc" ) {
502
+ if is_msvc ( ) {
496
503
// in order to allow HDF5_DIR to be pointed to a conda environment, we have
497
504
// to support MSVC as a special case (where the root is in $PREFIX/Library)
498
505
if let Some ( ref inc_dir) = config. inc_dir {
@@ -560,9 +567,7 @@ impl LibrarySearcher {
560
567
if link_paths. is_empty ( ) {
561
568
if let Some ( root_dir) = inc_dir. parent ( ) {
562
569
link_paths. push ( root_dir. join ( "lib" ) ) ;
563
- if cfg ! ( target_env = "msvc" ) {
564
- link_paths. push ( root_dir. join ( "bin" ) ) ;
565
- }
570
+ link_paths. push ( root_dir. join ( "bin" ) ) ;
566
571
}
567
572
}
568
573
let header = Header :: parse ( inc_dir) ;
@@ -594,7 +599,7 @@ impl Config {
594
599
println ! ( "cargo:rerun-if-env-changed=HDF5_DIR" ) ;
595
600
println ! ( "cargo:rerun-if-env-changed=HDF5_VERSION" ) ;
596
601
597
- if cfg ! ( target_env = "msvc" ) {
602
+ if is_msvc ( ) {
598
603
println ! ( "cargo:msvc_dll_indirection=1" ) ;
599
604
}
600
605
println ! ( "cargo:include={}" , self . inc_dir. to_str( ) . unwrap( ) ) ;
0 commit comments