cmGlobalUnixMakefileGenerator.cxx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
  20. }
  21. void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
  22. cmMakefile *mf)
  23. {
  24. mf->AddDefinition("CMAKE_CFG_INTDIR",".");
  25. this->cmGlobalGenerator::EnableLanguage(lang, mf);
  26. if(!lang)
  27. {
  28. lang = "CXX";
  29. }
  30. if(lang[0] == 'C')
  31. {
  32. if(!mf->GetDefinition("CMAKE_C_COMPILER"))
  33. {
  34. cmSystemTools::Error("CMAKE_C_COMPILER not set, after EnableLanguage");
  35. return;
  36. }
  37. const char* cc = mf->GetDefinition("CMAKE_C_COMPILER");
  38. std::string path = cmSystemTools::FindProgram(cc);
  39. if(path.size() == 0)
  40. {
  41. std::string message = "your C compiler: ";
  42. if(cc)
  43. {
  44. message += cc;
  45. }
  46. else
  47. {
  48. message += "(NULL)";
  49. }
  50. message += " was not found in your path. "
  51. "For CMake to correctly use try compile commands, the compiler must "
  52. "be in your path. Please add the compiler to your PATH environment,"
  53. " and re-run CMake.";
  54. cmSystemTools::Error(message.c_str());
  55. }
  56. if(strcmp(lang, "CXX") == 0)
  57. {
  58. const char* cxx = mf->GetDefinition("CMAKE_CXX_COMPILER");
  59. path = cmSystemTools::FindProgram(cxx);
  60. if(path.size() == 0)
  61. {
  62. std::string message = "your C++ compiler: ";
  63. if(cxx)
  64. {
  65. message += cxx;
  66. }
  67. else
  68. {
  69. message += "(NULL)";
  70. }
  71. message += " was not found in your path. "
  72. "For CMake to correctly use try compile commands, the compiler must "
  73. "be in your path. Please add the compiler to your PATH environment,"
  74. " and re-run CMake.";
  75. cmSystemTools::Error(message.c_str());
  76. }
  77. }
  78. }
  79. }
  80. ///! Create a local generator appropriate to this Global Generator
  81. cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
  82. {
  83. cmLocalGenerator *lg = new cmLocalUnixMakefileGenerator;
  84. lg->SetGlobalGenerator(this);
  85. return lg;
  86. }