Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CTest / cmCTestConfigureCommand.cxx
blobea5fce7fe9388d5159b660f2e97341712338a73e
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestConfigureCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2006/07/11 19:58:07 $
7 Version: $Revision: 1.11 $
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 "cmCTestConfigureCommand.h"
19 #include "cmCTest.h"
20 #include "cmCTestGenericHandler.h"
22 cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
24 if ( this->Values[ct_BUILD] )
26 this->CTest->SetCTestConfiguration("BuildDirectory",
27 cmSystemTools::CollapseFullPath(
28 this->Values[ct_BUILD]).c_str());
30 else
32 this->CTest->SetCTestConfiguration("BuildDirectory",
33 cmSystemTools::CollapseFullPath(
34 this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")).c_str());
36 if ( this->Values[ct_SOURCE] )
38 this->CTest->SetCTestConfiguration("SourceDirectory",
39 cmSystemTools::CollapseFullPath(
40 this->Values[ct_SOURCE]).c_str());
42 else
44 this->CTest->SetCTestConfiguration("SourceDirectory",
45 cmSystemTools::CollapseFullPath(
46 this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str());
48 if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() )
50 this->SetError("Build directory not specified. Either use BUILD "
51 "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
52 "variable");
53 return 0;
56 const char* ctestConfigureCommand
57 = this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
58 if ( ctestConfigureCommand && *ctestConfigureCommand )
60 this->CTest->SetCTestConfiguration("ConfigureCommand",
61 ctestConfigureCommand);
63 else
65 const char* cmakeGeneratorName
66 = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
67 if ( cmakeGeneratorName && *cmakeGeneratorName )
69 const std::string& source_dir
70 = this->CTest->GetCTestConfiguration("SourceDirectory");
71 if ( source_dir.empty() )
73 this->SetError("Source directory not specified. Either use SOURCE "
74 "argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY "
75 "variable");
76 return 0;
78 std::string cmakeConfigureCommand = "\"";
79 cmakeConfigureCommand += this->CTest->GetCMakeExecutable();
80 cmakeConfigureCommand += "\" \"-G";
81 cmakeConfigureCommand += cmakeGeneratorName;
82 cmakeConfigureCommand += "\" \"";
83 cmakeConfigureCommand += source_dir;
84 cmakeConfigureCommand += "\"";
85 this->CTest->SetCTestConfiguration("ConfigureCommand",
86 cmakeConfigureCommand.c_str());
88 else
90 this->SetError("Configure command is not specified. If this is a CMake "
91 "project, specify CTEST_CMAKE_GENERATOR, or if this is not CMake "
92 "project, specify CTEST_CONFIGURE_COMMAND.");
93 return 0;
97 cmCTestGenericHandler* handler
98 = this->CTest->GetInitializedHandler("configure");
99 if ( !handler )
101 this->SetError(
102 "internal CTest error. Cannot instantiate configure handler");
103 return 0;
105 return handler;