Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / CTest / cmCTestUpdateCommand.cxx
blob6a4153035f57a953de400ff959ed641d8eba21e1
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestUpdateCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2009-07-10 15:07:56 $
7 Version: $Revision: 1.18 $
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 "cmCTestUpdateCommand.h"
19 #include "cmCTest.h"
20 #include "cmCTestGenericHandler.h"
22 cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
24 if ( this->Values[ct_SOURCE] )
26 this->CTest->SetCTestConfiguration("SourceDirectory",
27 cmSystemTools::CollapseFullPath(
28 this->Values[ct_SOURCE]).c_str());
30 else
32 this->CTest->SetCTestConfiguration("SourceDirectory",
33 cmSystemTools::CollapseFullPath(
34 this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str());
36 std::string source_dir
37 = this->CTest->GetCTestConfiguration("SourceDirectory");
39 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
40 "UpdateCommand", "CTEST_UPDATE_COMMAND");
41 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
42 "UpdateOptions", "CTEST_UPDATE_OPTIONS");
43 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
44 "CVSCommand", "CTEST_CVS_COMMAND");
45 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
46 "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS");
47 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
48 "SVNCommand", "CTEST_SVN_COMMAND");
49 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
50 "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS");
51 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
52 "BZRCommand", "CTEST_BZR_COMMAND");
53 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
54 "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS");
55 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
56 "GITCommand", "CTEST_GIT_COMMAND");
57 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
58 "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS");
59 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
60 "HGCommand", "CTEST_HG_COMMAND");
61 this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
62 "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS");
64 const char* initialCheckoutCommand
65 = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
66 if ( !initialCheckoutCommand )
68 initialCheckoutCommand =
69 this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
72 cmCTestGenericHandler* handler
73 = this->CTest->GetInitializedHandler("update");
74 if ( !handler )
76 this->SetError("internal CTest error. Cannot instantiate update handler");
77 return 0;
79 handler->SetCommand(this);
80 if ( source_dir.empty() )
82 this->SetError("source directory not specified. Please use SOURCE tag");
83 return 0;
85 handler->SetOption("SourceDirectory", source_dir.c_str());
86 if ( initialCheckoutCommand )
88 handler->SetOption("InitialCheckout", initialCheckoutCommand);
90 if ( (!cmSystemTools::FileExists(source_dir.c_str()) ||
91 !cmSystemTools::FileIsDirectory(source_dir.c_str()))
92 && !initialCheckoutCommand )
94 cmOStringStream str;
95 str << "cannot find source directory: " << source_dir.c_str() << ".";
96 if ( !cmSystemTools::FileExists(source_dir.c_str()) )
98 str << " Looks like it is not checked out yet. Please specify "
99 "CTEST_CHECKOUT_COMMAND.";
101 this->SetError(str.str().c_str());
102 return 0;
104 return handler;