@@ -677,10 +677,17 @@ fn configure_cmake(
677
677
if !builder. is_builder_target ( target) {
678
678
cfg. define ( "CMAKE_CROSSCOMPILING" , "True" ) ;
679
679
680
+ // NOTE: Ideally, we wouldn't have to do this, and `cmake-rs` would just handle it for us.
681
+ // But it currently determines this basd on the `CARGO_CFG_TARGET_OS` environment variable,
682
+ // which isn't set when compiling outside `build.rs` (like bootstrap is).
683
+ //
684
+ // So for now, we define `CMAKE_SYSTEM_NAME` ourselves, to panicking in `cmake-rs`.
680
685
if target. contains ( "netbsd" ) {
681
686
cfg. define ( "CMAKE_SYSTEM_NAME" , "NetBSD" ) ;
682
687
} else if target. contains ( "dragonfly" ) {
683
688
cfg. define ( "CMAKE_SYSTEM_NAME" , "DragonFly" ) ;
689
+ } else if target. contains ( "openbsd" ) {
690
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "OpenBSD" ) ;
684
691
} else if target. contains ( "freebsd" ) {
685
692
cfg. define ( "CMAKE_SYSTEM_NAME" , "FreeBSD" ) ;
686
693
} else if target. is_windows ( ) {
@@ -691,10 +698,25 @@ fn configure_cmake(
691
698
cfg. define ( "CMAKE_SYSTEM_NAME" , "SunOS" ) ;
692
699
} else if target. contains ( "linux" ) {
693
700
cfg. define ( "CMAKE_SYSTEM_NAME" , "Linux" ) ;
701
+ } else if target. contains ( "darwin" ) {
702
+ // macOS
703
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Darwin" ) ;
704
+ } else if target. contains ( "ios" ) {
705
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "iOS" ) ;
706
+ } else if target. contains ( "tvos" ) {
707
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "tvOS" ) ;
708
+ } else if target. contains ( "visionos" ) {
709
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "visionOS" ) ;
710
+ } else if target. contains ( "watchos" ) {
711
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "watchOS" ) ;
712
+ } else if target. contains ( "none" ) {
713
+ // Last branch
714
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
694
715
} else {
695
716
builder. info ( & format ! (
696
717
"could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail" ,
697
718
) ) ;
719
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
698
720
}
699
721
700
722
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
0 commit comments