cmClassFile.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "cmClassFile.h"
  2. #include "cmStandardIncludes.h"
  3. #include "cmSystemTools.h"
  4. // Set the name of the class and the full path to the file.
  5. // The class must be found in dir and end in name.cxx, name.txx,
  6. // name.c or it will be considered a header file only class
  7. // and not included in the build process
  8. void cmClassFile::SetName(const char* name, const char* dir)
  9. {
  10. m_HeaderFileOnly = true;
  11. m_ClassName = name;
  12. std::string pathname = dir;
  13. if(pathname != "")
  14. {
  15. pathname += "/";
  16. }
  17. // First try and see whether the listed file can be found
  18. // as is without extensions added on.
  19. pathname += m_ClassName;
  20. std::string hname = pathname;
  21. if(cmSystemTools::FileExists(hname.c_str()))
  22. {
  23. m_HeaderFileOnly = false;
  24. m_FullPath = hname;
  25. return;
  26. }
  27. // Try various extentions
  28. hname = pathname;
  29. hname += ".cxx";
  30. if(cmSystemTools::FileExists(hname.c_str()))
  31. {
  32. m_HeaderFileOnly = false;
  33. m_FullPath = hname;
  34. return;
  35. }
  36. hname = pathname;
  37. hname += ".c";
  38. if(cmSystemTools::FileExists(hname.c_str()))
  39. {
  40. m_HeaderFileOnly = false;
  41. m_FullPath = hname;
  42. return;
  43. }
  44. hname = pathname;
  45. hname += ".txx";
  46. if(cmSystemTools::FileExists(hname.c_str()))
  47. {
  48. m_HeaderFileOnly = false;
  49. m_FullPath = hname;
  50. return;
  51. }
  52. hname = pathname;
  53. hname += ".h";
  54. if(!cmSystemTools::FileExists(hname.c_str()))
  55. {
  56. cmSystemTools::Error("can not find file ", hname.c_str());
  57. cmSystemTools::Error("Tried .txx .cxx .c for ", hname.c_str());
  58. }
  59. }
  60. void cmClassFile::Print()
  61. {
  62. if(m_AbstractClass)
  63. std::cout << "Abstract ";
  64. else
  65. std::cout << "Concrete ";
  66. if(m_HeaderFileOnly)
  67. std::cout << "Header file ";
  68. else
  69. std::cout << "CXX file ";
  70. std::cout << m_ClassName << std::endl;
  71. }