@@ -645,10 +645,17 @@ fn configure_cmake(
645645 if !builder. is_builder_target ( target) {
646646 cfg. define ( "CMAKE_CROSSCOMPILING" , "True" ) ;
647647
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`.
648653 if target. contains ( "netbsd" ) {
649654 cfg. define ( "CMAKE_SYSTEM_NAME" , "NetBSD" ) ;
650655 } else if target. contains ( "dragonfly" ) {
651656 cfg. define ( "CMAKE_SYSTEM_NAME" , "DragonFly" ) ;
657+ } else if target. contains ( "openbsd" ) {
658+ cfg. define ( "CMAKE_SYSTEM_NAME" , "OpenBSD" ) ;
652659 } else if target. contains ( "freebsd" ) {
653660 cfg. define ( "CMAKE_SYSTEM_NAME" , "FreeBSD" ) ;
654661 } else if target. is_windows ( ) {
@@ -659,10 +666,25 @@ fn configure_cmake(
659666 cfg. define ( "CMAKE_SYSTEM_NAME" , "SunOS" ) ;
660667 } else if target. contains ( "linux" ) {
661668 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" ) ;
662683 } else {
663684 builder. info ( & format ! (
664685 "could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail" ,
665686 ) ) ;
687+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
666688 }
667689
668690 // When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
0 commit comments