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 "cmCTestGenericHandler.h"
|
||||
|
||||
cmCTestConfigureCommand::cmCTestConfigureCommand()
|
||||
{
|
||||
this->Arguments[ctc_OPTIONS] = "OPTIONS";
|
||||
this->Arguments[ctc_LAST] = 0;
|
||||
this->Last = ctc_LAST;
|
||||
}
|
||||
|
||||
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] )
|
||||
{
|
||||
this->CTest->SetCTestConfiguration("BuildDirectory",
|
||||
|
@ -33,6 +47,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||
cmSystemTools::CollapseFullPath(
|
||||
this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")).c_str());
|
||||
}
|
||||
|
||||
if ( this->Values[ct_SOURCE] )
|
||||
{
|
||||
this->CTest->SetCTestConfiguration("SourceDirectory",
|
||||
|
@ -45,6 +60,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||
cmSystemTools::CollapseFullPath(
|
||||
this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str());
|
||||
}
|
||||
|
||||
if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() )
|
||||
{
|
||||
this->SetError("Build directory not specified. Either use BUILD "
|
||||
|
@ -77,11 +93,26 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||
}
|
||||
std::string cmakeConfigureCommand = "\"";
|
||||
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 += "\" \"";
|
||||
cmakeConfigureCommand += "\"";
|
||||
|
||||
cmakeConfigureCommand += " \"";
|
||||
cmakeConfigureCommand += source_dir;
|
||||
cmakeConfigureCommand += "\"";
|
||||
|
||||
this->CTest->SetCTestConfiguration("ConfigureCommand",
|
||||
cmakeConfigureCommand.c_str());
|
||||
}
|
||||
|
@ -104,5 +135,3 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
class cmCTestConfigureCommand : public cmCTestHandlerCommand
|
||||
{
|
||||
public:
|
||||
|
||||
cmCTestConfigureCommand() {}
|
||||
cmCTestConfigureCommand();
|
||||
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
|
@ -60,10 +59,12 @@ public:
|
|||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
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 "
|
||||
"Configure.xml. The second argument is a variable that will hold "
|
||||
"return value.";
|
||||
"Configure.xml. The OPTIONS arguments are passed as command line "
|
||||
"arguments to the configure command. "
|
||||
"The RETURN_VALUE argument is a variable that will hold "
|
||||
"the return value.";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
|
||||
|
@ -71,6 +72,11 @@ public:
|
|||
protected:
|
||||
cmCTestGenericHandler* InitializeHandler();
|
||||
|
||||
enum {
|
||||
ctc_FIRST = ct_LAST,
|
||||
ctc_OPTIONS,
|
||||
ctc_LAST
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ int cmCTestConfigureHandler::ProcessHandler()
|
|||
if (! res || retVal )
|
||||
{
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Error(s) when updating the project" << std::endl);
|
||||
"Error(s) when configuring the project" << std::endl);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -123,8 +123,10 @@ bool cmCTestGenericHandler::StartResultingXML(const char* name,
|
|||
if(this->CTest->GetCurrentTag().empty())
|
||||
{
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Current Tag empty, this may mean"
|
||||
" NightlyStartTime was not set correctly." << std::endl);
|
||||
"Current Tag empty, this may mean NightlyStartTime / "
|
||||
"CTEST_NIGHTLY_START_TIME was not set correctly. Or "
|
||||
"maybe you forgot to call ctest_start() before calling "
|
||||
"ctest_configure()." << std::endl);
|
||||
cmSystemTools::SetFatalErrorOccured();
|
||||
return false;
|
||||
}
|
||||
|
@ -175,4 +177,3 @@ bool cmCTestGenericHandler::StartLogFile(const char* name,
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue