Skip to content

Commit 4815c27

Browse files
author
Alexander Regueiro
committed
respect CMAKE env var, and look for cmake3 before cmake executable
1 parent e9e7c50 commit 4815c27

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bootstrap/sanity.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ pub fn check(build: &mut Build) {
9292
})
9393
.any(|build_llvm_ourselves| build_llvm_ourselves);
9494
if building_llvm || build.config.sanitizers {
95-
cmd_finder.must_have("cmake");
95+
// Choose CMake executable with the following priority:
96+
// 1. `CMAKE` env var, if set.
97+
// 2. `cmake3`, if it exists.
98+
// 3. `cmake`.
99+
if let Some(cmake_path) = env::var_os("CMAKE") {
100+
cmd_finder.must_have(cmake_path);
101+
} else if cmd_finder.maybe_have("cmake3").is_some() {
102+
env::set_var("CMAKE", "cmake3");
103+
} else {
104+
cmd_finder.must_have("cmake");
105+
}
96106
}
97107

98108
// Ninja is currently only used for LLVM itself.
@@ -228,7 +238,8 @@ pub fn check(build: &mut Build) {
228238
// There are three builds of cmake on windows: MSVC, MinGW, and
229239
// Cygwin. The Cygwin build does not have generators for Visual
230240
// Studio, so detect that here and error.
231-
let out = output(Command::new("cmake").arg("--help"));
241+
let cmake_path = env::var("CMAKE").unwrap_or("cmake".into());
242+
let out = output(Command::new(cmake_path).arg("--help"));
232243
if !out.contains("Visual Studio") {
233244
panic!(
234245
"

0 commit comments

Comments
 (0)