cmEnableTestingCommand.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmEnableTestingCommand.h"
  14. #include "cmCacheManager.h"
  15. // we do this in the final pass so that we now the subdirs have all
  16. // been defined
  17. void cmEnableTestingCommand::FinalPass()
  18. {
  19. // Create a full path filename for output Testfile
  20. std::string fname;
  21. fname = m_Makefile->GetStartOutputDirectory();
  22. fname += "/";
  23. fname += "DartTestfile.txt";
  24. cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory());
  25. // Open the output Testfile
  26. std::ofstream fout(fname.c_str());
  27. if (!fout)
  28. {
  29. cmSystemTools::Error("Error Writing ", fname.c_str());
  30. return;
  31. }
  32. fout << "# CMake generated Testfile for " << std::endl
  33. << "#\tSource directory: "
  34. << m_Makefile->GetStartDirectory()
  35. << std::endl
  36. << "#\tBuild directory: " << m_Makefile->GetStartOutputDirectory()
  37. << std::endl
  38. << "# " << std::endl
  39. << "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source"
  40. << std::endl
  41. << "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands"
  42. << std::endl
  43. << "# that are excluded by CMake control structures, i.e. IF() commands."
  44. << std::endl
  45. << "#" << std::endl
  46. << "# The next line is critical for Dart to work" << std::endl
  47. << "# Duh :-)" << std::endl << std::endl;
  48. // write out the subdirs for the current directory
  49. if (!m_Makefile->GetSubDirectories().empty())
  50. {
  51. fout << "SUBDIRS(";
  52. const std::vector<std::string>& subdirs = m_Makefile->GetSubDirectories();
  53. std::vector<std::string>::const_iterator i = subdirs.begin();
  54. fout << (*i).c_str();
  55. ++i;
  56. for(; i != subdirs.end(); ++i)
  57. {
  58. fout << " " << (*i).c_str();
  59. }
  60. fout << ")" << std::endl << std::endl;;
  61. }
  62. fout.close();
  63. return;
  64. }