cmCableSourceFilesCommand.cxx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmCableSourceFilesCommand.h"
  12. #include "cmCacheManager.h"
  13. void cmCableSourceFilesCommand::FinalPass()
  14. {
  15. // Get the index of the current package's cmClassFile.
  16. // If it doesn't exist, ignore this command.
  17. int index = m_CableData->GetPackageClassIndex();
  18. if(index < 0)
  19. { return; }
  20. // The package's file has not yet been generated yet. The dependency
  21. // finder will need hints. Add one for each source file.
  22. cmClassFile& cFile = m_Makefile->GetClasses()[index];
  23. std::string curPath = m_Makefile->GetCurrentDirectory();
  24. curPath += "/";
  25. for(Entries::const_iterator f = m_Entries.begin();
  26. f != m_Entries.end(); ++f)
  27. {
  28. std::string header = curPath+*f+".h";
  29. cFile.m_Depends.push_back(header);
  30. }
  31. }
  32. /**
  33. * Write the CABLE configuration code to indicate header dependencies for
  34. * a package.
  35. */
  36. void cmCableSourceFilesCommand::WriteConfiguration() const
  37. {
  38. std::ostream& os = m_CableData->GetOutputStream();
  39. cmCableData::Indentation indent = m_CableData->GetIndentation();
  40. cmRegularExpression needCdataBlock("[&<>]");
  41. // Look for the files on a path relative to the current CMakeLists.txt.
  42. std::string curPath = m_Makefile->GetCurrentDirectory();
  43. curPath += "/";
  44. os << indent << "<Headers>" << std::endl;
  45. for(Entries::const_iterator f = m_Entries.begin();
  46. f != m_Entries.end(); ++f)
  47. {
  48. std::string file = curPath+*f;
  49. // Look for the normal include file.
  50. std::string header = file+".h";
  51. if(cmSystemTools::FileExists(header.c_str()))
  52. {
  53. os << indent << " <File name=\"" << header.c_str() << "\"/>"
  54. << std::endl;
  55. }
  56. else
  57. {
  58. cmSystemTools::Error("Unable to find source file ", header.c_str());
  59. }
  60. // Look for an instantiation file.
  61. std::string instantiation = file+".txx";
  62. if(cmSystemTools::FileExists(instantiation.c_str()))
  63. {
  64. os << indent << " <File name=\"" << instantiation.c_str()
  65. << "\" purpose=\"instantiate\"/>" << std::endl;
  66. }
  67. }
  68. os << indent << "</Headers>" << std::endl;
  69. }