cmGlobalMSYSMakefileGenerator.cxx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmGlobalMSYSMakefileGenerator.h"
  14. #include "cmLocalUnixMakefileGenerator3.h"
  15. #include "cmMakefile.h"
  16. #include "cmake.h"
  17. cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
  18. {
  19. this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
  20. this->ForceUnixPaths = true;
  21. this->ToolSupportsColorVT100 = true;
  22. }
  23. std::string
  24. cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc)
  25. {
  26. std::string fstab = makeloc;
  27. fstab += "/../etc/fstab";
  28. std::ifstream fin(fstab.c_str());
  29. std::string path;
  30. std::string mount;
  31. std::string mingwBin;
  32. while(fin)
  33. {
  34. fin >> path;
  35. fin >> mount;
  36. if(mount == "/mingw")
  37. {
  38. mingwBin = path;
  39. mingwBin += "/bin";
  40. }
  41. }
  42. return mingwBin;
  43. }
  44. void cmGlobalMSYSMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
  45. cmMakefile *mf)
  46. {
  47. this->FindMakeProgram(mf);
  48. std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
  49. std::vector<std::string> locations;
  50. std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str());
  51. locations.push_back(this->FindMinGW(makeloc));
  52. locations.push_back(makeloc);
  53. locations.push_back("/mingw/bin");
  54. locations.push_back("c:/mingw/bin");
  55. std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
  56. std::string gcc = "gcc.exe";
  57. if(tgcc.size())
  58. {
  59. gcc = tgcc;
  60. }
  61. std::string tgxx = cmSystemTools::FindProgram("g++", locations);
  62. std::string gxx = "g++.exe";
  63. if(tgxx.size())
  64. {
  65. gxx = tgxx;
  66. }
  67. mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
  68. mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
  69. this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf);
  70. if(!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile())
  71. {
  72. cmSystemTools::Error("CMAKE_AR was not found, please set to archive program. ",
  73. mf->GetDefinition("CMAKE_AR"));
  74. }
  75. }
  76. ///! Create a local generator appropriate to this Global Generator
  77. cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator()
  78. {
  79. cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
  80. lg->SetWindowsShell(false);
  81. lg->SetGlobalGenerator(this);
  82. lg->SetIgnoreLibPrefix(true);
  83. lg->SetPassMakeflags(false);
  84. lg->SetUnixCD(true);
  85. return lg;
  86. }
  87. //----------------------------------------------------------------------------
  88. void cmGlobalMSYSMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
  89. {
  90. entry.name = this->GetName();
  91. entry.brief = "Generates MSYS makefiles.";
  92. entry.full = "The makefiles use /bin/sh as the shell. They require msys to be installed on the machine.";
  93. }