diff options
author | scivision <scivision@users.noreply.github.com> | 2023-08-21 04:40:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-09-11 12:47:09 (GMT) |
commit | 6ebf0e1a46ddc3a93421b33af7ffc99f2c89c282 (patch) | |
tree | 2350e45854e10583f1ee2947bee8f4da4718e56d /Source/cmGlobalNinjaGenerator.cxx | |
parent | 1345928f9693a038153c43f09128bac0419d91ed (diff) | |
download | CMake-6ebf0e1a46ddc3a93421b33af7ffc99f2c89c282.zip CMake-6ebf0e1a46ddc3a93421b33af7ffc99f2c89c282.tar.gz CMake-6ebf0e1a46ddc3a93421b33af7ffc99f2c89c282.tar.bz2 |
Ninja: Use absolute path to COMSPEC if possible
If the COMSPEC is set to an absolute path, use it instead of just
`cmd.exe`. This avoids searching for the tool in the current working
directory and the `PATH`. If COMSPEC is not set to an absolute path,
fall back to the existing behavior.
Issue: #18350
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 54c3737..30305a1 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -554,6 +554,15 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) { #ifdef _WIN32 cm->GetState()->SetWindowsShell(true); + + // Attempt to use full path to COMSPEC, default "cmd.exe" + std::string comspec; + if (cmSystemTools::GetEnv("COMSPEC", comspec) && + cmSystemTools::FileIsFullPath(comspec)) { + this->Comspec = comspec; + } else { + this->Comspec = "cmd.exe"; + } #endif this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake"; } |