cmGlobalMSYSMakefileGenerator.cxx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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->ToolSupportsColor = 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
  45. ::EnableLanguage(std::vector<std::string>const& l, 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
  73. ("CMAKE_AR was not found, please set to archive program. ",
  74. mf->GetDefinition("CMAKE_AR"));
  75. }
  76. }
  77. ///! Create a local generator appropriate to this Global Generator
  78. cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator()
  79. {
  80. cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
  81. lg->SetWindowsShell(false);
  82. lg->SetGlobalGenerator(this);
  83. lg->SetIgnoreLibPrefix(true);
  84. lg->SetPassMakeflags(false);
  85. lg->SetUnixCD(true);
  86. return lg;
  87. }
  88. //----------------------------------------------------------------------------
  89. void cmGlobalMSYSMakefileGenerator
  90. ::GetDocumentation(cmDocumentationEntry& entry) const
  91. {
  92. entry.name = this->GetName();
  93. entry.brief = "Generates MSYS makefiles.";
  94. entry.full = "The makefiles use /bin/sh as the shell. "
  95. "They require msys to be installed on the machine.";
  96. }