cmEnableTestingCommand.cxx 2.5 KB

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