File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,17 @@ pub fn check(build: &mut Build) {
92
92
} )
93
93
. any ( |build_llvm_ourselves| build_llvm_ourselves) ;
94
94
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
+ }
96
106
}
97
107
98
108
// Ninja is currently only used for LLVM itself.
@@ -228,7 +238,8 @@ pub fn check(build: &mut Build) {
228
238
// There are three builds of cmake on windows: MSVC, MinGW, and
229
239
// Cygwin. The Cygwin build does not have generators for Visual
230
240
// 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" ) ) ;
232
243
if !out. contains ( "Visual Studio" ) {
233
244
panic ! (
234
245
"
You can’t perform that action at this time.
0 commit comments