@@ -677,10 +677,17 @@ fn configure_cmake(
677677 if !builder. is_builder_target ( target) {
678678 cfg. define ( "CMAKE_CROSSCOMPILING" , "True" ) ;
679679
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`.
680685 if target. contains ( "netbsd" ) {
681686 cfg. define ( "CMAKE_SYSTEM_NAME" , "NetBSD" ) ;
682687 } else if target. contains ( "dragonfly" ) {
683688 cfg. define ( "CMAKE_SYSTEM_NAME" , "DragonFly" ) ;
689+ } else if target. contains ( "openbsd" ) {
690+ cfg. define ( "CMAKE_SYSTEM_NAME" , "OpenBSD" ) ;
684691 } else if target. contains ( "freebsd" ) {
685692 cfg. define ( "CMAKE_SYSTEM_NAME" , "FreeBSD" ) ;
686693 } else if target. is_windows ( ) {
@@ -691,10 +698,25 @@ fn configure_cmake(
691698 cfg. define ( "CMAKE_SYSTEM_NAME" , "SunOS" ) ;
692699 } else if target. contains ( "linux" ) {
693700 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" ) ;
694715 } else {
695716 builder. info ( & format ! (
696717 "could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail" ,
697718 ) ) ;
719+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
698720 }
699721
700722 // When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
0 commit comments