File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,7 @@ impl Config {
514
514
// Build up the first cmake command to build the build system.
515
515
let executable = self
516
516
. getenv_target_os ( "CMAKE" )
517
+ . or_else ( || find_cmake_executable ( & target) )
517
518
. unwrap_or ( OsString :: from ( "cmake" ) ) ;
518
519
let mut cmd = Command :: new ( & executable) ;
519
520
@@ -965,3 +966,28 @@ fn getenv_unwrap(v: &str) -> String {
965
966
fn fail ( s : & str ) -> ! {
966
967
panic ! ( "\n {}\n \n build script failed, must exit now" , s)
967
968
}
969
+
970
+ #[ cfg( windows) ]
971
+ fn find_cmake_executable ( target : & str ) -> Option < OsString > {
972
+ use cc:: windows_registry:: find_tool;
973
+
974
+ // Try to find cmake.exe bundled with MSVC, but only if there isn't another one in path
975
+ let cmake_in_path = env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or ( OsString :: new ( ) ) )
976
+ . any ( |p| p. join ( "cmake.exe" ) . exists ( ) ) ;
977
+ if cmake_in_path {
978
+ None
979
+ } else {
980
+ find_tool ( target, "devenv" ) . and_then ( |t| {
981
+ t. path ( )
982
+ . join ( "..\\ CommonExtensions\\ Microsoft\\ CMake\\ CMake\\ bin\\ cmake.exe" )
983
+ . canonicalize ( )
984
+ . ok ( )
985
+ . map ( OsString :: from)
986
+ } )
987
+ }
988
+ }
989
+
990
+ #[ cfg( not( windows) ) ]
991
+ fn find_cmake_executable ( target : & str ) -> Option < OsString > {
992
+ None
993
+ }
You can’t perform that action at this time.
0 commit comments