cmSystemTools: Teach MaybePrependCmdExe to always use backslashes

This commit is contained in:
Brad King
2025-02-03 09:08:08 -05:00
parent 817b3967f8
commit c1f6b04176

View File

@@ -802,6 +802,8 @@ cmsys::Status cmSystemTools::MaybePrependCmdExe(
output.reserve(cmdLine.size() + 2);
output.emplace_back(cmSystemTools::GetComspec());
output.emplace_back("/c");
// Convert the batch file path to use backslashes for cmd.exe to parse.
std::replace(applicationName.begin(), applicationName.end(), '/', '\\');
if (applicationName.find(' ') != std::string::npos) {
// Convert the batch file path to a short path to avoid spaces.
// Otherwise, cmd.exe may not handle arguments with spaces.