@@ -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 based 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,34 @@ 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
+ // FIXME(madsmtm): compiler-rt's CMake setup is kinda weird, it seems like they do
674
+ // version testing etc. for macOS (i.e. Darwin), even while building for iOS?
675
+ //
676
+ // So for now we set it to "Darwin", but ideally this should be set to "iOS".
677
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Darwin" ) ;
678
+ } else if target. contains ( "tvos" ) {
679
+ // FIXME(madsmtm): See above, we should be using "tvOS" here.
680
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Darwin" ) ;
681
+ } else if target. contains ( "visionos" ) {
682
+ // FIXME(madsmtm): See above, we should be using "visionOS" here.
683
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Darwin" ) ;
684
+ } else if target. contains ( "watchos" ) {
685
+ // FIXME(madsmtm): See above, we should be using "watchOS" here.
686
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Darwin" ) ;
687
+ } else if target. contains ( "none" ) {
688
+ // "none" should be the last branch
689
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
662
690
} else {
663
691
builder. info ( & format ! (
664
692
"could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail" ,
665
693
) ) ;
694
+ // Fallback, set `CMAKE_SYSTEM_NAME` anyhow to avoid the logic `cmake-rs` tries, and
695
+ // to avoid CMAKE_SYSTEM_NAME being inferred from the host.
696
+ cfg. define ( "CMAKE_SYSTEM_NAME" , "Generic" ) ;
666
697
}
667
698
668
699
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
@@ -672,7 +703,7 @@ fn configure_cmake(
672
703
// CMakeFiles (and then only in tests), and so far no issues have been
673
704
// reported, the system version is currently left unset.
674
705
675
- if target. contains ( "darwin " ) {
706
+ if target. contains ( "apple " ) {
676
707
// Make sure that CMake does not build universal binaries on macOS.
677
708
// Explicitly specify the one single target architecture.
678
709
if target. starts_with ( "aarch64" ) {
0 commit comments