cmGlobalMinGWMakefileGenerator.cxx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmGlobalMinGWMakefileGenerator.h"
  11. #include "cmLocalUnixMakefileGenerator3.h"
  12. #include "cmMakefile.h"
  13. cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator()
  14. {
  15. this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake";
  16. this->ForceUnixPaths = true;
  17. this->ToolSupportsColor = true;
  18. this->UseLinkScript = true;
  19. }
  20. void cmGlobalMinGWMakefileGenerator
  21. ::EnableLanguage(std::vector<std::string>const& l,
  22. cmMakefile *mf,
  23. bool optional)
  24. {
  25. this->FindMakeProgram(mf);
  26. std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
  27. std::vector<std::string> locations;
  28. locations.push_back(cmSystemTools::GetProgramPath(makeProgram.c_str()));
  29. locations.push_back("/mingw/bin");
  30. locations.push_back("c:/mingw/bin");
  31. std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
  32. std::string gcc = "gcc.exe";
  33. if(tgcc.size())
  34. {
  35. gcc = tgcc;
  36. }
  37. std::string tgxx = cmSystemTools::FindProgram("g++", locations);
  38. std::string gxx = "g++.exe";
  39. if(tgxx.size())
  40. {
  41. gxx = tgxx;
  42. }
  43. mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
  44. mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
  45. this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
  46. }
  47. ///! Create a local generator appropriate to this Global Generator
  48. cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator()
  49. {
  50. cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
  51. lg->SetWindowsShell(true);
  52. lg->SetGlobalGenerator(this);
  53. lg->SetIgnoreLibPrefix(true);
  54. lg->SetPassMakeflags(false);
  55. lg->SetUnixCD(true);
  56. lg->SetMinGWMake(true);
  57. // mingw32-make has trouble running code like
  58. //
  59. // @echo message with spaces
  60. //
  61. // If quotes are added
  62. //
  63. // @echo "message with spaces"
  64. //
  65. // it runs but the quotes are displayed. Instead just use cmake to
  66. // echo.
  67. lg->SetNativeEchoCommand("@$(CMAKE_COMMAND) -E echo ", false);
  68. return lg;
  69. }
  70. //----------------------------------------------------------------------------
  71. void cmGlobalMinGWMakefileGenerator
  72. ::GetDocumentation(cmDocumentationEntry& entry) const
  73. {
  74. entry.Name = this->GetName();
  75. entry.Brief = "Generates a make file for use with mingw32-make.";
  76. entry.Full = "The makefiles generated use cmd.exe as the shell. "
  77. "They do not require msys or a unix shell.";
  78. }