bootstrap: Always set CMAKE_SYSTEM_NAME when cross-compiling
To avoid a panic in cmake-rs that was introduced in: https://github.com/rust-lang/cmake-rs/pull/158
This commit is contained in:
parent
c83504faef
commit
9cf05b893d
1 changed files with 24 additions and 0 deletions
|
|
@ -645,10 +645,17 @@ fn configure_cmake(
|
|||
if !builder.is_builder_target(target) {
|
||||
cfg.define("CMAKE_CROSSCOMPILING", "True");
|
||||
|
||||
// NOTE: Ideally, we wouldn't have to do this, and `cmake-rs` would just handle it for us.
|
||||
// But it currently determines this based on the `CARGO_CFG_TARGET_OS` environment variable,
|
||||
// which isn't set when compiling outside `build.rs` (like bootstrap is).
|
||||
//
|
||||
// So for now, we define `CMAKE_SYSTEM_NAME` ourselves, to panicking in `cmake-rs`.
|
||||
if target.contains("netbsd") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
|
||||
} else if target.contains("dragonfly") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
|
||||
} else if target.contains("openbsd") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "OpenBSD");
|
||||
} else if target.contains("freebsd") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
|
||||
} else if target.is_windows() {
|
||||
|
|
@ -659,10 +666,27 @@ fn configure_cmake(
|
|||
cfg.define("CMAKE_SYSTEM_NAME", "SunOS");
|
||||
} else if target.contains("linux") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "Linux");
|
||||
} else if target.contains("darwin") {
|
||||
// macOS
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "Darwin");
|
||||
} else if target.contains("ios") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "iOS");
|
||||
} else if target.contains("tvos") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "tvOS");
|
||||
} else if target.contains("visionos") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "visionOS");
|
||||
} else if target.contains("watchos") {
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "watchOS");
|
||||
} else if target.contains("none") {
|
||||
// "none" should be the last branch
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "Generic");
|
||||
} else {
|
||||
builder.info(&format!(
|
||||
"could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail",
|
||||
));
|
||||
// Fallback, set `CMAKE_SYSTEM_NAME` anyhow to avoid the logic `cmake-rs` tries, and
|
||||
// to avoid CMAKE_SYSTEM_NAME being inferred from the host.
|
||||
cfg.define("CMAKE_SYSTEM_NAME", "Generic");
|
||||
}
|
||||
|
||||
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue