Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CTest / cmCTestStartCommand.cxx
blob140811c2be4546332a46a6cda0a41c3d013c72aa
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestStartCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/23 15:28:01 $
7 Version: $Revision: 1.16 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmCTestStartCommand.h"
19 #include "cmCTest.h"
20 #include "cmLocalGenerator.h"
21 #include "cmGlobalGenerator.h"
23 bool cmCTestStartCommand
24 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
26 if (args.size() < 1)
28 this->SetError("called with incorrect number of arguments");
29 return false;
32 size_t cnt = 0;
33 const char* smodel = args[cnt].c_str();
34 const char* src_dir = 0;
35 const char* bld_dir = 0;
37 cnt++;
39 this->CTest->SetSpecificTrack(0);
40 if ( cnt < args.size() -1 )
42 if ( args[cnt] == "TRACK" )
44 cnt ++;
45 this->CTest->SetSpecificTrack(args[cnt].c_str());
46 cnt ++;
50 if ( cnt < args.size() )
52 src_dir = args[cnt].c_str();
53 cnt ++;
54 if ( cnt < args.size() )
56 bld_dir = args[cnt].c_str();
59 if ( !src_dir )
61 src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
63 if ( !bld_dir)
65 bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
67 if ( !src_dir )
69 this->SetError("source directory not specified. Specify source directory "
70 "as an argument or set CTEST_SOURCE_DIRECTORY");
71 return false;
73 if ( !bld_dir)
75 this->SetError("binary directory not specified. Specify binary directory "
76 "as an argument or set CTEST_BINARY_DIRECTORY");
77 return false;
80 cmSystemTools::AddKeepPath(src_dir);
81 cmSystemTools::AddKeepPath(bld_dir);
83 this->CTest->EmptyCTestConfiguration();
84 this->CTest->SetCTestConfiguration("SourceDirectory",
85 cmSystemTools::CollapseFullPath(src_dir).c_str());
86 this->CTest->SetCTestConfiguration("BuildDirectory",
87 cmSystemTools::CollapseFullPath(bld_dir).c_str());
89 cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
90 << smodel << std::endl
91 << " Source directory: " << src_dir << std::endl
92 << " Build directory: " << bld_dir << std::endl);
93 const char* track = this->CTest->GetSpecificTrack();
94 if ( track )
96 cmCTestLog(this->CTest, HANDLER_OUTPUT,
97 " Track: " << track << std::endl);
100 this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
101 this->CTest->SetSuppressUpdatingCTestConfiguration(true);
102 int model = this->CTest->GetTestModelFromString(smodel);
103 this->CTest->SetTestModel(model);
104 this->CTest->SetProduceXML(true);
106 return this->CTest->InitializeFromCommand(this, true);