1
0

cmGlobalUnixMakefileGenerator.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 "cmGlobalUnixMakefileGenerator.h"
  14. #include "cmLocalUnixMakefileGenerator.h"
  15. #include "cmMakefile.h"
  16. #include "cmake.h"
  17. cmGlobalUnixMakefileGenerator::cmGlobalUnixMakefileGenerator()
  18. {
  19. // This type of makefile always requires unix style paths
  20. m_ForceUnixPaths = true;
  21. m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
  22. }
  23. void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
  24. cmMakefile *mf)
  25. {
  26. mf->AddDefinition("CMAKE_CFG_INTDIR",".");
  27. this->cmGlobalGenerator::EnableLanguage(lang, mf);
  28. if(!lang)
  29. {
  30. lang = "CXX";
  31. }
  32. if(lang[0] == 'C')
  33. {
  34. if(!mf->GetDefinition("CMAKE_C_COMPILER"))
  35. {
  36. cmSystemTools::Error("CMAKE_C_COMPILER not set, after EnableLanguage");
  37. return;
  38. }
  39. const char* cc = mf->GetDefinition("CMAKE_C_COMPILER");
  40. std::string path = cmSystemTools::FindProgram(cc);
  41. if(path.size() == 0)
  42. {
  43. std::string message = "your C compiler: ";
  44. if(cc)
  45. {
  46. message += cc;
  47. }
  48. else
  49. {
  50. message += "(NULL)";
  51. }
  52. message += " was not found in your path. "
  53. "For CMake to correctly use try compile commands, the compiler must "
  54. "be in your path. Please add the compiler to your PATH environment,"
  55. " and re-run CMake.";
  56. cmSystemTools::Error(message.c_str());
  57. }
  58. if(strcmp(lang, "CXX") == 0)
  59. {
  60. const char* cxx = mf->GetDefinition("CMAKE_CXX_COMPILER");
  61. path = cmSystemTools::FindProgram(cxx);
  62. if(path.size() == 0)
  63. {
  64. std::string message = "your C++ compiler: ";
  65. if(cxx)
  66. {
  67. message += cxx;
  68. }
  69. else
  70. {
  71. message += "(NULL)";
  72. }
  73. message += " was not found in your path. "
  74. "For CMake to correctly use try compile commands, the compiler must "
  75. "be in your path. Please add the compiler to your PATH environment,"
  76. " and re-run CMake.";
  77. cmSystemTools::Error(message.c_str());
  78. }
  79. }
  80. }
  81. }
  82. ///! Create a local generator appropriate to this Global Generator
  83. cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
  84. {
  85. cmLocalGenerator *lg = new cmLocalUnixMakefileGenerator;
  86. lg->SetGlobalGenerator(this);
  87. return lg;
  88. }
  89. //----------------------------------------------------------------------------
  90. void cmGlobalUnixMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
  91. {
  92. entry.name = this->GetName();
  93. entry.brief = "Generates standard UNIX makefiles.";
  94. entry.full =
  95. "A hierarchy of UNIX makefiles is generated into the build tree. Any "
  96. "standard UNIX-style make program can build the project through the "
  97. "default make target. A \"make install\" target is also provided.";
  98. }