cmAuxSourceDirectoryCommand.cxx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 "cmAuxSourceDirectoryCommand.h"
  12. #include "cmDirectory.h"
  13. // cmAuxSourceDirectoryCommand
  14. bool cmAuxSourceDirectoryCommand::Invoke(std::vector<std::string>& args)
  15. {
  16. if(args.size() < 2 || args.size() > 2)
  17. {
  18. this->SetError("called with incorrect number of arguments");
  19. return false;
  20. }
  21. std::string templateDirectory = args[0];
  22. m_Makefile->AddExtraDirectory(templateDirectory.c_str());
  23. std::string tdir = m_Makefile->GetCurrentDirectory();
  24. tdir += "/";
  25. tdir += templateDirectory;
  26. // Load all the files in the directory
  27. cmDirectory dir;
  28. if(dir.Load(tdir.c_str()))
  29. {
  30. int numfiles = dir.GetNumberOfFiles();
  31. for(int i =0; i < numfiles; ++i)
  32. {
  33. std::string file = dir.GetFile(i);
  34. // ignore files less than f.cxx in length
  35. if(file.size() > 4)
  36. {
  37. // Remove the extension
  38. std::string::size_type dotpos = file.rfind(".");
  39. file = file.substr(0, dotpos);
  40. std::string fullname = templateDirectory;
  41. fullname += "/";
  42. fullname += file;
  43. // add the file as a class file so
  44. // depends can be done
  45. cmClassFile cmfile;
  46. cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory());
  47. cmfile.m_AbstractClass = false;
  48. m_Makefile->AddClass(cmfile,args[1].c_str());
  49. }
  50. }
  51. }
  52. return true;
  53. }