@@ -568,6 +568,15 @@ impl Library {
568568 }
569569
570570 fn parse_libs_cflags ( & mut self , name : & str , output : & [ u8 ] , config : & Config ) {
571+ #[ cfg( windows) ]
572+ lazy_static:: lazy_static! {
573+ static ref LIB_BASENAME : regex:: Regex = regex:: Regex :: new( r"^(.*)\.(lib|dll)$" ) . unwrap( ) ;
574+ }
575+ #[ cfg( not( windows) ) ]
576+ lazy_static:: lazy_static! {
577+ static ref LIB_BASENAME : regex:: Regex = regex:: Regex :: new( r"^lib(.*)\.(a|so|dylib)" ) . unwrap( ) ;
578+ }
579+
571580 let mut is_msvc = false ;
572581 if let Ok ( target) = env:: var ( "TARGET" ) {
573582 if target. contains ( "msvc" ) {
@@ -669,7 +678,28 @@ impl Library {
669678 self . include_paths . push ( PathBuf :: from ( inc) ) ;
670679 }
671680 }
672- _ => ( ) ,
681+ _ => {
682+ let path = std:: path:: Path :: new ( part) ;
683+ if path. is_file ( ) {
684+ // Cargo doesn't have a means to directly specify a file path to link,
685+ // so split up the path into the parent directory and library name.
686+ if let Some ( dir) = path. parent ( ) {
687+ let link_search = format ! ( "rustc-link-search={}" , dir. display( ) ) ;
688+ config. print_metadata ( & link_search) ;
689+ }
690+ if let Some ( file_name) = path. file_name ( ) {
691+ // libQt5Core.a becomes Qt5Core
692+ // libQt5Core.so.5 becomes Qt5Core
693+ if let Some ( captures) =
694+ LIB_BASENAME . captures ( & file_name. to_string_lossy ( ) )
695+ {
696+ let lib_basename = captures. get ( 1 ) . unwrap ( ) . as_str ( ) ;
697+ let link_lib = format ! ( "rustc-link-lib={}" , lib_basename) ;
698+ config. print_metadata ( & link_lib) ;
699+ }
700+ }
701+ }
702+ }
673703 }
674704 }
675705
0 commit comments