cmEnableTestingCommand.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // we do this in the final pass so that we now the subdirs have all
  15. // been defined
  16. void cmEnableTestingCommand::FinalPass()
  17. {
  18. // Create a full path filename for output Testfile
  19. std::string fname;
  20. fname = m_Makefile->GetStartOutputDirectory();
  21. fname += "/";
  22. fname += "DartTestfile.txt";
  23. cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory());
  24. // Open the output Testfile
  25. std::ofstream fout(fname.c_str());
  26. if (!fout)
  27. {
  28. cmSystemTools::Error("Error Writing ", fname.c_str());
  29. return;
  30. }
  31. fout << "# CMake generated Testfile for " << std::endl
  32. << "#\tSource directory: "
  33. << m_Makefile->GetStartDirectory()
  34. << std::endl
  35. << "#\tBuild directory: " << m_Makefile->GetStartOutputDirectory()
  36. << std::endl
  37. << "# " << std::endl
  38. << "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source"
  39. << std::endl
  40. << "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands"
  41. << std::endl
  42. << "# that are excluded by CMake control structures, i.e. IF() commands."
  43. << std::endl
  44. << "#" << std::endl
  45. << "# The next line is critical for Dart to work" << std::endl
  46. << "# Duh :-)" << std::endl << std::endl;
  47. // write out the subdirs for the current directory
  48. if (!m_Makefile->GetSubDirectories().empty())
  49. {
  50. fout << "SUBDIRS(";
  51. const std::vector<std::string>& subdirs = m_Makefile->GetSubDirectories();
  52. std::vector<std::string>::const_iterator i = subdirs.begin();
  53. fout << (*i).c_str();
  54. ++i;
  55. for(; i != subdirs.end(); ++i)
  56. {
  57. fout << " " << (*i).c_str();
  58. }
  59. fout << ")" << std::endl << std::endl;;
  60. }
  61. fout.close();
  62. return;
  63. }