cmGlobalMinGWMakefileGenerator.cxx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "cmGlobalMinGWMakefileGenerator.h"
  4. #include "cmDocumentationEntry.h"
  5. #include "cmLocalUnixMakefileGenerator3.h"
  6. #include "cmMakefile.h"
  7. #include "cmState.h"
  8. #include "cmake.h"
  9. cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator(cmake* cm)
  10. : cmGlobalUnixMakefileGenerator3(cm)
  11. {
  12. this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake";
  13. this->ForceUnixPaths = true;
  14. this->ToolSupportsColor = true;
  15. this->UseLinkScript = true;
  16. cm->GetState()->SetWindowsShell(true);
  17. cm->GetState()->SetMinGWMake(true);
  18. }
  19. void cmGlobalMinGWMakefileGenerator::EnableLanguage(
  20. std::vector<std::string> const& l, cmMakefile* mf, bool optional)
  21. {
  22. this->FindMakeProgram(mf);
  23. const std::string& makeProgram =
  24. mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
  25. std::vector<std::string> locations;
  26. locations.push_back(cmSystemTools::GetProgramPath(makeProgram));
  27. locations.push_back("/mingw/bin");
  28. locations.push_back("c:/mingw/bin");
  29. std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
  30. std::string gcc = "gcc.exe";
  31. if (!tgcc.empty()) {
  32. gcc = tgcc;
  33. }
  34. std::string tgxx = cmSystemTools::FindProgram("g++", locations);
  35. std::string gxx = "g++.exe";
  36. if (!tgxx.empty()) {
  37. gxx = tgxx;
  38. }
  39. std::string trc = cmSystemTools::FindProgram("windres", locations);
  40. std::string rc = "windres.exe";
  41. if (!trc.empty()) {
  42. rc = trc;
  43. }
  44. mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
  45. mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
  46. mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
  47. this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
  48. }
  49. void cmGlobalMinGWMakefileGenerator::GetDocumentation(
  50. cmDocumentationEntry& entry)
  51. {
  52. entry.Name = cmGlobalMinGWMakefileGenerator::GetActualName();
  53. entry.Brief = "Generates a make file for use with mingw32-make.";
  54. }