@@ -443,55 +443,53 @@ impl Config {
443
443
if !self . defined ( "CMAKE_TOOLCHAIN_FILE" ) {
444
444
if let Some ( s) = self . getenv_target_os ( "CMAKE_TOOLCHAIN_FILE" ) {
445
445
self . define ( "CMAKE_TOOLCHAIN_FILE" , s) ;
446
- } else {
447
- if target. contains ( "redox" ) {
448
- if !self . defined ( "CMAKE_SYSTEM_NAME" ) {
449
- self . define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
450
- }
451
- } else if target != host && !self . defined ( "CMAKE_SYSTEM_NAME" ) {
452
- // Set CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR when cross compiling
453
- let os = getenv_unwrap ( "CARGO_CFG_TARGET_OS" ) ;
454
- let arch = getenv_unwrap ( "CARGO_CFG_TARGET_ARCH" ) ;
455
- // CMAKE_SYSTEM_NAME list
456
- // https://gitlab.kitware.com/cmake/cmake/-/issues/21489#note_1077167
457
- //
458
- // CMAKE_SYSTEM_PROCESSOR
459
- // some of the values come from https://en.wikipedia.org/wiki/Uname
460
- let ( system_name, system_processor) = match ( os. as_str ( ) , arch. as_str ( ) ) {
461
- ( "android" , arch) => ( "Android" , arch) ,
462
- ( "dragonfly" , arch) => ( "DragonFly" , arch) ,
463
- ( "macos" , "x86_64" ) => ( "Darwin" , "x86_64" ) ,
464
- ( "macos" , "aarch64" ) => ( "Darwin" , "arm64" ) ,
465
- ( "freebsd" , "x86_64" ) => ( "FreeBSD" , "amd64" ) ,
466
- ( "freebsd" , arch) => ( "FreeBSD" , arch) ,
467
- ( "fuchsia" , arch) => ( "Fuchsia" , arch) ,
468
- ( "haiku" , arch) => ( "Haiku" , arch) ,
469
- ( "ios" , "aarch64" ) => ( "iOS" , "arm64" ) ,
470
- ( "ios" , arch) => ( "iOS" , arch) ,
471
- ( "linux" , arch) => {
472
- let name = "Linux" ;
473
- match arch {
474
- "powerpc" => ( name, "ppc" ) ,
475
- "powerpc64" => ( name, "ppc64" ) ,
476
- "powerpc64le" => ( name, "ppc64le" ) ,
477
- _ => ( name, arch) ,
478
- }
479
- }
480
- ( "netbsd" , arch) => ( "NetBSD" , arch) ,
481
- ( "openbsd" , "x86_64" ) => ( "OpenBSD" , "amd64" ) ,
482
- ( "openbsd" , arch) => ( "OpenBSD" , arch) ,
483
- ( "solaris" , arch) => ( "SunOS" , arch) ,
484
- ( "tvos" , arch) => ( "tvOS" , arch) ,
485
- ( "watchos" , arch) => ( "watchOS" , arch) ,
486
- ( "windows" , "x86_64" ) => ( "Windows" , "AMD64" ) ,
487
- ( "windows" , "x86" ) => ( "Windows" , "X86" ) ,
488
- ( "windows" , "aarch64" ) => ( "Windows" , "ARM64" ) ,
489
- // Others
490
- ( os, arch) => ( os, arch) ,
491
- } ;
492
- self . define ( "CMAKE_SYSTEM_NAME" , system_name) ;
493
- self . define ( "CMAKE_SYSTEM_PROCESSOR" , system_processor) ;
446
+ } else if target. contains ( "redox" ) {
447
+ if !self . defined ( "CMAKE_SYSTEM_NAME" ) {
448
+ self . define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
494
449
}
450
+ } else if target != host && !self . defined ( "CMAKE_SYSTEM_NAME" ) {
451
+ // Set CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR when cross compiling
452
+ let os = getenv_unwrap ( "CARGO_CFG_TARGET_OS" ) ;
453
+ let arch = getenv_unwrap ( "CARGO_CFG_TARGET_ARCH" ) ;
454
+ // CMAKE_SYSTEM_NAME list
455
+ // https://gitlab.kitware.com/cmake/cmake/-/issues/21489#note_1077167
456
+ //
457
+ // CMAKE_SYSTEM_PROCESSOR
458
+ // some of the values come from https://en.wikipedia.org/wiki/Uname
459
+ let ( system_name, system_processor) = match ( os. as_str ( ) , arch. as_str ( ) ) {
460
+ ( "android" , arch) => ( "Android" , arch) ,
461
+ ( "dragonfly" , arch) => ( "DragonFly" , arch) ,
462
+ ( "macos" , "x86_64" ) => ( "Darwin" , "x86_64" ) ,
463
+ ( "macos" , "aarch64" ) => ( "Darwin" , "arm64" ) ,
464
+ ( "freebsd" , "x86_64" ) => ( "FreeBSD" , "amd64" ) ,
465
+ ( "freebsd" , arch) => ( "FreeBSD" , arch) ,
466
+ ( "fuchsia" , arch) => ( "Fuchsia" , arch) ,
467
+ ( "haiku" , arch) => ( "Haiku" , arch) ,
468
+ ( "ios" , "aarch64" ) => ( "iOS" , "arm64" ) ,
469
+ ( "ios" , arch) => ( "iOS" , arch) ,
470
+ ( "linux" , arch) => {
471
+ let name = "Linux" ;
472
+ match arch {
473
+ "powerpc" => ( name, "ppc" ) ,
474
+ "powerpc64" => ( name, "ppc64" ) ,
475
+ "powerpc64le" => ( name, "ppc64le" ) ,
476
+ _ => ( name, arch) ,
477
+ }
478
+ }
479
+ ( "netbsd" , arch) => ( "NetBSD" , arch) ,
480
+ ( "openbsd" , "x86_64" ) => ( "OpenBSD" , "amd64" ) ,
481
+ ( "openbsd" , arch) => ( "OpenBSD" , arch) ,
482
+ ( "solaris" , arch) => ( "SunOS" , arch) ,
483
+ ( "tvos" , arch) => ( "tvOS" , arch) ,
484
+ ( "watchos" , arch) => ( "watchOS" , arch) ,
485
+ ( "windows" , "x86_64" ) => ( "Windows" , "AMD64" ) ,
486
+ ( "windows" , "x86" ) => ( "Windows" , "X86" ) ,
487
+ ( "windows" , "aarch64" ) => ( "Windows" , "ARM64" ) ,
488
+ // Others
489
+ ( os, arch) => ( os, arch) ,
490
+ } ;
491
+ self . define ( "CMAKE_SYSTEM_NAME" , system_name) ;
492
+ self . define ( "CMAKE_SYSTEM_PROCESSOR" , system_processor) ;
495
493
}
496
494
}
497
495
@@ -550,7 +548,7 @@ impl Config {
550
548
let mut cmake_prefix_path = Vec :: new ( ) ;
551
549
for dep in & self . deps {
552
550
let dep = dep. to_uppercase ( ) . replace ( '-' , "_" ) ;
553
- if let Some ( root) = env:: var_os ( & format ! ( "DEP_{}_ROOT" , dep) ) {
551
+ if let Some ( root) = env:: var_os ( format ! ( "DEP_{}_ROOT" , dep) ) {
554
552
cmake_prefix_path. push ( PathBuf :: from ( root) ) ;
555
553
}
556
554
}
@@ -627,14 +625,11 @@ impl Config {
627
625
// If we're on MSVC we need to be sure to use the right generator or
628
626
// otherwise we won't get 32/64 bit correct automatically.
629
627
// This also guarantees that NMake generator isn't chosen implicitly.
630
- let using_nmake_generator = {
631
- if generator. is_none ( ) {
632
- cmd. arg ( "-G" ) . arg ( self . visual_studio_generator ( & target) ) ;
633
- false
634
- } else {
635
- generator. as_ref ( ) . unwrap ( ) == "NMake Makefiles"
636
- || generator. as_ref ( ) . unwrap ( ) == "NMake Makefiles JOM"
637
- }
628
+ let using_nmake_generator = if let Some ( g) = & generator {
629
+ g == "NMake Makefiles" || g == "NMake Makefiles JOM"
630
+ } else {
631
+ cmd. arg ( "-G" ) . arg ( self . visual_studio_generator ( & target) ) ;
632
+ false
638
633
} ;
639
634
if !is_ninja && !using_nmake_generator {
640
635
if target. contains ( "x86_64" ) {
@@ -661,15 +656,13 @@ impl Config {
661
656
panic ! ( "unsupported msvc target: {}" , target) ;
662
657
}
663
658
}
664
- } else if target. contains ( "darwin" ) {
665
- if !self . defined ( "CMAKE_OSX_ARCHITECTURES" ) {
666
- if target. contains ( "x86_64" ) {
667
- cmd. arg ( "-DCMAKE_OSX_ARCHITECTURES=x86_64" ) ;
668
- } else if target. contains ( "aarch64" ) {
669
- cmd. arg ( "-DCMAKE_OSX_ARCHITECTURES=arm64" ) ;
670
- } else {
671
- panic ! ( "unsupported darwin target: {}" , target) ;
672
- }
659
+ } else if target. contains ( "darwin" ) && !self . defined ( "CMAKE_OSX_ARCHITECTURES" ) {
660
+ if target. contains ( "x86_64" ) {
661
+ cmd. arg ( "-DCMAKE_OSX_ARCHITECTURES=x86_64" ) ;
662
+ } else if target. contains ( "aarch64" ) {
663
+ cmd. arg ( "-DCMAKE_OSX_ARCHITECTURES=arm64" ) ;
664
+ } else {
665
+ panic ! ( "unsupported darwin target: {}" , target) ;
673
666
}
674
667
}
675
668
if let Some ( ref generator) = generator {
@@ -679,7 +672,7 @@ impl Config {
679
672
cmd. arg ( "-T" ) . arg ( generator_toolset) ;
680
673
}
681
674
let profile = self . get_profile ( ) . to_string ( ) ;
682
- for & ( ref k , ref v) in & self . defines {
675
+ for ( k , v) in & self . defines {
683
676
let mut os = OsString :: from ( "-D" ) ;
684
677
os. push ( k) ;
685
678
os. push ( "=" ) ;
@@ -696,7 +689,7 @@ impl Config {
696
689
let build_type = self
697
690
. defines
698
691
. iter ( )
699
- . find ( |& & ( ref a, _) | a == "CMAKE_BUILD_TYPE" )
692
+ . find ( |& ( a, _) | a == "CMAKE_BUILD_TYPE" )
700
693
. map ( |x| x. 1 . to_str ( ) . unwrap ( ) )
701
694
. unwrap_or ( & profile) ;
702
695
let build_type_upcase = build_type
@@ -798,14 +791,14 @@ impl Config {
798
791
}
799
792
800
793
if !self . defined ( "CMAKE_BUILD_TYPE" ) {
801
- cmd. arg ( & format ! ( "-DCMAKE_BUILD_TYPE={}" , profile) ) ;
794
+ cmd. arg ( format ! ( "-DCMAKE_BUILD_TYPE={}" , profile) ) ;
802
795
}
803
796
804
797
if self . verbose_make {
805
798
cmd. arg ( "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" ) ;
806
799
}
807
800
808
- for & ( ref k , ref v) in c_compiler. env ( ) . iter ( ) . chain ( & self . env ) {
801
+ for ( k , v) in c_compiler. env ( ) . iter ( ) . chain ( & self . env ) {
809
802
cmd. env ( k, v) ;
810
803
}
811
804
@@ -820,13 +813,13 @@ impl Config {
820
813
let mut cmd = self . cmake_build_command ( & target) ;
821
814
cmd. current_dir ( & build) ;
822
815
823
- for & ( ref k , ref v) in c_compiler. env ( ) . iter ( ) . chain ( & self . env ) {
816
+ for ( k , v) in c_compiler. env ( ) . iter ( ) . chain ( & self . env ) {
824
817
cmd. env ( k, v) ;
825
818
}
826
819
827
820
// If the generated project is Makefile based we should carefully transfer corresponding CARGO_MAKEFLAGS
828
821
let mut use_jobserver = false ;
829
- if fs:: metadata ( & build. join ( "Makefile" ) ) . is_ok ( ) {
822
+ if fs:: metadata ( build. join ( "Makefile" ) ) . is_ok ( ) {
830
823
match env:: var_os ( "CARGO_MAKEFLAGS" ) {
831
824
// Only do this on non-windows and non-bsd
832
825
// On Windows, we could be invoking make instead of
@@ -967,7 +960,7 @@ impl Config {
967
960
}
968
961
969
962
fn defined ( & self , var : & str ) -> bool {
970
- self . defines . iter ( ) . any ( |& ( ref a, _) | a == var)
963
+ self . defines . iter ( ) . any ( |( a, _) | a == var)
971
964
}
972
965
973
966
// If a cmake project has previously been built (e.g. CMakeCache.txt already
0 commit comments