cmGlobalMSYSMakefileGenerator.cxx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmGlobalMSYSMakefileGenerator.h"
  4. #include <cmext/string_view>
  5. #include "cmsys/FStream.hxx"
  6. #include "cmMakefile.h"
  7. #include "cmState.h"
  8. #include "cmStringAlgorithms.h"
  9. #include "cmSystemTools.h"
  10. #include "cmake.h"
  11. cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator(cmake* cm)
  12. : cmGlobalUnixMakefileGenerator3(cm)
  13. {
  14. this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
  15. this->ForceUnixPaths = true;
  16. this->ToolSupportsColor = true;
  17. this->UseLinkScript = false;
  18. cm->GetState()->SetMSYSShell(true);
  19. }
  20. std::string cmGlobalMSYSMakefileGenerator::FindMinGW(
  21. std::string const& makeloc)
  22. {
  23. std::string fstab = cmStrCat(makeloc, "/../etc/fstab");
  24. cmsys::ifstream fin(fstab.c_str());
  25. std::string path;
  26. std::string mount;
  27. std::string mingwBin;
  28. while (fin) {
  29. fin >> path;
  30. fin >> mount;
  31. if (mount == "/mingw"_s) {
  32. mingwBin = cmStrCat(path, "/bin");
  33. }
  34. }
  35. return mingwBin;
  36. }
  37. void cmGlobalMSYSMakefileGenerator::EnableLanguage(
  38. std::vector<std::string> const& l, cmMakefile* mf, bool optional)
  39. {
  40. mf->AddDefinition("MSYS", "1");
  41. this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
  42. if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() &&
  43. !(1 == l.size() && l[0] == "NONE"_s)) {
  44. cmSystemTools::Error(
  45. "CMAKE_AR was not found, please set to archive program. " +
  46. mf->GetSafeDefinition("CMAKE_AR"));
  47. }
  48. }
  49. cmDocumentationEntry cmGlobalMSYSMakefileGenerator::GetDocumentation()
  50. {
  51. return { cmGlobalMSYSMakefileGenerator::GetActualName(),
  52. "Generates MSYS makefiles." };
  53. }