1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestUpdateCommand.cxx,v $
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"
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());
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");
76 this->SetError("internal CTest error. Cannot instantiate update handler");
79 handler
->SetCommand(this);
80 if ( source_dir
.empty() )
82 this->SetError("source directory not specified. Please use SOURCE tag");
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
)
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());