ENH: Add OPTIONS argument to the ctest_configure command so that you can pass -D arguments to the cmake configure step from a ctest -S script. Also clarify/correct some not so helpful error messages.
This commit is contained in:
parent
b640257884
commit
9457ca3cf5
@ -19,8 +19,22 @@
|
|||||||
#include "cmCTest.h"
|
#include "cmCTest.h"
|
||||||
#include "cmCTestGenericHandler.h"
|
#include "cmCTestGenericHandler.h"
|
||||||
|
|
||||||
|
cmCTestConfigureCommand::cmCTestConfigureCommand()
|
||||||
|
{
|
||||||
|
this->Arguments[ctc_OPTIONS] = "OPTIONS";
|
||||||
|
this->Arguments[ctc_LAST] = 0;
|
||||||
|
this->Last = ctc_LAST;
|
||||||
|
}
|
||||||
|
|
||||||
cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> options;
|
||||||
|
|
||||||
|
if (this->Values[ctc_OPTIONS])
|
||||||
|
{
|
||||||
|
cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options);
|
||||||
|
}
|
||||||
|
|
||||||
if ( this->Values[ct_BUILD] )
|
if ( this->Values[ct_BUILD] )
|
||||||
{
|
{
|
||||||
this->CTest->SetCTestConfiguration("BuildDirectory",
|
this->CTest->SetCTestConfiguration("BuildDirectory",
|
||||||
@ -33,6 +47,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||||||
cmSystemTools::CollapseFullPath(
|
cmSystemTools::CollapseFullPath(
|
||||||
this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")).c_str());
|
this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this->Values[ct_SOURCE] )
|
if ( this->Values[ct_SOURCE] )
|
||||||
{
|
{
|
||||||
this->CTest->SetCTestConfiguration("SourceDirectory",
|
this->CTest->SetCTestConfiguration("SourceDirectory",
|
||||||
@ -45,6 +60,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||||||
cmSystemTools::CollapseFullPath(
|
cmSystemTools::CollapseFullPath(
|
||||||
this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str());
|
this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() )
|
if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() )
|
||||||
{
|
{
|
||||||
this->SetError("Build directory not specified. Either use BUILD "
|
this->SetError("Build directory not specified. Either use BUILD "
|
||||||
@ -77,11 +93,26 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||||||
}
|
}
|
||||||
std::string cmakeConfigureCommand = "\"";
|
std::string cmakeConfigureCommand = "\"";
|
||||||
cmakeConfigureCommand += this->CTest->GetCMakeExecutable();
|
cmakeConfigureCommand += this->CTest->GetCMakeExecutable();
|
||||||
cmakeConfigureCommand += "\" \"-G";
|
cmakeConfigureCommand += "\"";
|
||||||
|
|
||||||
|
std::vector<std::string>::const_iterator it;
|
||||||
|
std::string option;
|
||||||
|
for (it= options.begin(); it!=options.end(); ++it)
|
||||||
|
{
|
||||||
|
option = *it;
|
||||||
|
cmakeConfigureCommand += " \"";
|
||||||
|
cmakeConfigureCommand += option;
|
||||||
|
cmakeConfigureCommand += "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
cmakeConfigureCommand += " \"-G";
|
||||||
cmakeConfigureCommand += cmakeGeneratorName;
|
cmakeConfigureCommand += cmakeGeneratorName;
|
||||||
cmakeConfigureCommand += "\" \"";
|
cmakeConfigureCommand += "\"";
|
||||||
|
|
||||||
|
cmakeConfigureCommand += " \"";
|
||||||
cmakeConfigureCommand += source_dir;
|
cmakeConfigureCommand += source_dir;
|
||||||
cmakeConfigureCommand += "\"";
|
cmakeConfigureCommand += "\"";
|
||||||
|
|
||||||
this->CTest->SetCTestConfiguration("ConfigureCommand",
|
this->CTest->SetCTestConfiguration("ConfigureCommand",
|
||||||
cmakeConfigureCommand.c_str());
|
cmakeConfigureCommand.c_str());
|
||||||
}
|
}
|
||||||
@ -104,5 +135,3 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||||||
}
|
}
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
class cmCTestConfigureCommand : public cmCTestHandlerCommand
|
class cmCTestConfigureCommand : public cmCTestHandlerCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
cmCTestConfigureCommand();
|
||||||
cmCTestConfigureCommand() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a virtual constructor for the command.
|
* This is a virtual constructor for the command.
|
||||||
@ -60,10 +59,12 @@ public:
|
|||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
" ctest_configure(BUILD build_dir RETURN_VALUE res)\n"
|
" ctest_configure(BUILD build_dir OPTIONS options RETURN_VALUE res)\n"
|
||||||
"Configures the given build directory and stores results in "
|
"Configures the given build directory and stores results in "
|
||||||
"Configure.xml. The second argument is a variable that will hold "
|
"Configure.xml. The OPTIONS arguments are passed as command line "
|
||||||
"return value.";
|
"arguments to the configure command. "
|
||||||
|
"The RETURN_VALUE argument is a variable that will hold "
|
||||||
|
"the return value.";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
|
cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
|
||||||
@ -71,6 +72,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
cmCTestGenericHandler* InitializeHandler();
|
cmCTestGenericHandler* InitializeHandler();
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ctc_FIRST = ct_LAST,
|
||||||
|
ctc_OPTIONS,
|
||||||
|
ctc_LAST
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ int cmCTestConfigureHandler::ProcessHandler()
|
|||||||
<< std::endl
|
<< std::endl
|
||||||
<< "\t<StartConfigureTime>" << start_time_time
|
<< "\t<StartConfigureTime>" << start_time_time
|
||||||
<< "</StartConfigureTime>\n";
|
<< "</StartConfigureTime>\n";
|
||||||
|
|
||||||
if ( res == cmsysProcess_State_Exited && retVal )
|
if ( res == cmsysProcess_State_Exited && retVal )
|
||||||
{
|
{
|
||||||
os << retVal;
|
os << retVal;
|
||||||
@ -129,7 +129,7 @@ int cmCTestConfigureHandler::ProcessHandler()
|
|||||||
if (! res || retVal )
|
if (! res || retVal )
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"Error(s) when updating the project" << std::endl);
|
"Error(s) when configuring the project" << std::endl);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -123,8 +123,10 @@ bool cmCTestGenericHandler::StartResultingXML(const char* name,
|
|||||||
if(this->CTest->GetCurrentTag().empty())
|
if(this->CTest->GetCurrentTag().empty())
|
||||||
{
|
{
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"Current Tag empty, this may mean"
|
"Current Tag empty, this may mean NightlyStartTime / "
|
||||||
" NightlyStartTime was not set correctly." << std::endl);
|
"CTEST_NIGHTLY_START_TIME was not set correctly. Or "
|
||||||
|
"maybe you forgot to call ctest_start() before calling "
|
||||||
|
"ctest_configure()." << std::endl);
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -175,4 +177,3 @@ bool cmCTestGenericHandler::StartLogFile(const char* name,
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user