| 478 | |
| 479 | #ifdef _WIN32 |
| 480 | std::string FindMSYSTEM_PREFIX(std::vector<std::string> prefixes) |
| 481 | { |
| 482 | for (std::string const& prefix : prefixes) { |
| 483 | std::string out; |
| 484 | std::string err; |
| 485 | int ret; |
| 486 | // In a modern MSYSTEM environment we expect cygpath to be in PATH. |
| 487 | std::vector<std::string> cygpath_cmd{ "cygpath", "-w", prefix }; |
| 488 | if (cmSystemTools::RunSingleCommand(cygpath_cmd, &out, &err, &ret, nullptr, |
| 489 | cmSystemTools::OUTPUT_NONE)) { |
| 490 | if (ret == 0) { |
| 491 | out = cmTrimWhitespace(out); |
| 492 | cmSystemTools::ConvertToUnixSlashes(out); |
| 493 | if (cmSystemTools::FileIsDirectory(out)) { |
| 494 | return out; |
| 495 | } |
| 496 | } |
| 497 | } else { |
| 498 | // In a legacy MSYSTEM environment (MinGW/MSYS 1.0) there is no |
| 499 | // cygpath but we expect 'sh' to be in PATH. |
| 500 | std::vector<std::string> sh_cmd{ |
| 501 | "sh", "-c", cmStrCat("cd \"", prefix, "\" && cmd //c cd") |
| 502 | }; |
| 503 | if (cmSystemTools::RunSingleCommand(sh_cmd, &out, &err, &ret, nullptr, |
| 504 | cmSystemTools::OUTPUT_NONE)) { |
| 505 | if (ret == 0) { |
| 506 | out = cmTrimWhitespace(out); |
| 507 | cmSystemTools::ConvertToUnixSlashes(out); |
| 508 | if (cmSystemTools::FileIsDirectory(out)) { |
| 509 | return out; |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | return {}; |
| 516 | } |
| 517 | |
| 518 | std::string FallbackMSYSTEM_PREFIX(cm::string_view msystem) |
| 519 | { |
no test coverage detected
searching dependent graphs…