cmGlobalMSYSMakefileGenerator.cxx 1.7 KB

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