@@ -645,10 +645,17 @@ fn configure_cmake(
645
645
if !builder. is_builder_target ( target) {
646
646
cfg. define ( "CMAKE_CROSSCOMPILING" , "True" ) ;
647
647
648
+ // NOTE: Ideally, we wouldn't have to do this, and `cmake-rs` would just handle it for us.
649
+ // But it currently determines this basd on the `CARGO_CFG_TARGET_OS` environment variable,
650
+ // which isn't set when compiling outside `build.rs` (like bootstrap is).
651
+ //
652
+ // So for now, we define `CMAKE_SYSTEM_NAME` ourselves, to panicking in `cmake-rs`.
648
653
if target. contains ( "netbsd" ) {
649
654
cfg. define ( "CMAKE_SYSTEM_NAME" , "NetBSD" ) ;
650
655
} else if target. contains ( "dragonfly" ) {
651
656
cfg. define ( "CMAKE_SYSTEM_NAME" , "DragonFly" ) ;
657
+ } else if target. contains ( "openbsd" ) {
658
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "OpenBSD" ) ;
652
659
} else if target. contains ( "freebsd" ) {
653
660
cfg. define ( "CMAKE_SYSTEM_NAME" , "FreeBSD" ) ;
654
661
} else if target. is_windows ( ) {
@@ -659,10 +666,25 @@ fn configure_cmake(
659
666
cfg. define ( "CMAKE_SYSTEM_NAME" , "SunOS" ) ;
660
667
} else if target. contains ( "linux" ) {
661
668
cfg. define ( "CMAKE_SYSTEM_NAME" , "Linux" ) ;
669
+ } else if target. contains ( "darwin" ) {
670
+ // macOS
671
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Darwin" ) ;
672
+ } else if target. contains ( "ios" ) {
673
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "iOS" ) ;
674
+ } else if target. contains ( "tvos" ) {
675
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "tvOS" ) ;
676
+ } else if target. contains ( "visionos" ) {
677
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "visionOS" ) ;
678
+ } else if target. contains ( "watchos" ) {
679
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "watchOS" ) ;
680
+ } else if target. contains ( "none" ) {
681
+ // Last branch
682
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
662
683
} else {
663
684
builder. info ( & format ! (
664
685
"could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail" ,
665
686
) ) ;
687
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
666
688
}
667
689
668
690
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
0 commit comments