cmGlobalMinGWMakefileGenerator.cxx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. std::string trc = cmSystemTools::FindProgram("windres", locations);
  44. std::string rc = "windres.exe";
  45. if(trc.size())
  46. {
  47. rc = trc;
  48. }
  49. mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
  50. mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
  51. mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
  52. this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
  53. }
  54. ///! Create a local generator appropriate to this Global Generator
  55. cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator()
  56. {
  57. cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
  58. lg->SetWindowsShell(true);
  59. lg->SetGlobalGenerator(this);
  60. lg->SetIgnoreLibPrefix(true);
  61. lg->SetPassMakeflags(false);
  62. lg->SetUnixCD(true);
  63. lg->SetMinGWMake(true);
  64. return lg;
  65. }
  66. //----------------------------------------------------------------------------
  67. void cmGlobalMinGWMakefileGenerator
  68. ::GetDocumentation(cmDocumentationEntry& entry) const
  69. {
  70. entry.Name = this->GetName();
  71. entry.Brief = "Generates a make file for use with mingw32-make.";
  72. entry.Full = "The makefiles generated use cmd.exe as the shell. "
  73. "They do not require msys or a unix shell.";
  74. }