cmGlobalUnixMakefileGenerator.cxx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. std::string path = cmSystemTools::FindProgram(mf->GetDefinition("CMAKE_C_COMPILER"));
  38. if(path.size() == 0)
  39. {
  40. std::string message = "your C compiler: ";
  41. message += mf->GetDefinition("CMAKE_C_COMPILER");
  42. message += " was not found in your path. "
  43. "For CMake to correctly use try compile commands, the compiler must "
  44. "be in your path. Please add the compiler to your PATH environment,"
  45. " and re-run CMake.";
  46. cmSystemTools::Error(message.c_str());
  47. }
  48. if(strcmp(lang, "CXX") == 0)
  49. {
  50. path = cmSystemTools::FindProgram(mf->GetDefinition("CMAKE_CXX_COMPILER"));
  51. if(path.size() == 0)
  52. {
  53. std::string message = "your C++ compiler: ";
  54. message += mf->GetDefinition("CMAKE_CXX_COMPILER");
  55. message += " was not found in your path. "
  56. "For CMake to correctly use try compile commands, the compiler must "
  57. "be in your path. Please add the compiler to your PATH environment,"
  58. " and re-run CMake.";
  59. cmSystemTools::Error(message.c_str());
  60. }
  61. }
  62. }
  63. }
  64. ///! Create a local generator appropriate to this Global Generator
  65. cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
  66. {
  67. cmLocalGenerator *lg = new cmLocalUnixMakefileGenerator;
  68. lg->SetGlobalGenerator(this);
  69. return lg;
  70. }