cmCTestStartCommand.cxx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "cmCTestStartCommand.h"
  14. #include "cmCTest.h"
  15. #include "cmLocalGenerator.h"
  16. #include "cmGlobalGenerator.h"
  17. bool cmCTestStartCommand::InitialPass(
  18. std::vector<std::string> const& args)
  19. {
  20. if (args.size() < 1)
  21. {
  22. this->SetError("called with incorrect number of arguments");
  23. return false;
  24. }
  25. const char* smodel = args[0].c_str();
  26. const char* src_dir = 0;
  27. const char* bld_dir = 0;
  28. if ( args.size() >= 2 )
  29. {
  30. src_dir = args[1].c_str();
  31. if ( args.size() == 3 )
  32. {
  33. bld_dir = args[2].c_str();
  34. }
  35. }
  36. if ( args.size() > 3 )
  37. {
  38. this->SetError("called with incorrect number of arguments");
  39. return false;
  40. }
  41. if ( !src_dir )
  42. {
  43. src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
  44. }
  45. if ( !bld_dir)
  46. {
  47. bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
  48. }
  49. if ( !src_dir )
  50. {
  51. this->SetError("source directory not specified. Specify source directory "
  52. "as an argument or set CTEST_SOURCE_DIRECTORY");
  53. return false;
  54. }
  55. if ( !bld_dir)
  56. {
  57. this->SetError("binary directory not specified. Specify binary directory "
  58. "as an argument or set CTEST_BINARY_DIRECTORY");
  59. return false;
  60. }
  61. this->CTest->EmptyCTestConfiguration();
  62. this->CTest->SetCTestConfiguration("SourceDirectory", src_dir);
  63. this->CTest->SetCTestConfiguration("BuildDirectory", bld_dir);
  64. cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
  65. << smodel << std::endl
  66. << " Source directory: " << src_dir << std::endl
  67. << " Build directory: " << bld_dir << std::endl);
  68. this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
  69. this->CTest->SetSuppressUpdatingCTestConfiguration(true);
  70. int model = this->CTest->GetTestModelFromString(smodel);
  71. this->CTest->SetTestModel(model);
  72. this->CTest->SetProduceXML(true);
  73. return this->CTest->InitializeFromCommand(this, true);
  74. }