ENH: improve backwards compatibility
This commit is contained in:
parent
abf2054765
commit
c3ab83150c
@ -35,6 +35,92 @@
|
|||||||
|
|
||||||
#include <memory> // auto_ptr
|
#include <memory> // auto_ptr
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
class cmCTestSubdirCommand : public cmCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* This is a virtual constructor for the command.
|
||||||
|
*/
|
||||||
|
virtual cmCommand* Clone()
|
||||||
|
{
|
||||||
|
cmCTestSubdirCommand* c = new cmCTestSubdirCommand;
|
||||||
|
c->TestHandler = this->TestHandler;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called when the command is first encountered in
|
||||||
|
* the CMakeLists.txt file.
|
||||||
|
*/
|
||||||
|
virtual bool InitialPass(std::vector<std::string> const& args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the command as specified in CMakeList.txt.
|
||||||
|
*/
|
||||||
|
virtual const char* GetName() { return "subdirs";}
|
||||||
|
|
||||||
|
// Unused methods
|
||||||
|
virtual const char* GetTerseDocumentation() { return ""; }
|
||||||
|
virtual const char* GetFullDocumentation() { return ""; }
|
||||||
|
|
||||||
|
cmTypeMacro(cmCTestSubdirCommand, cmCommand);
|
||||||
|
|
||||||
|
cmCTestTestHandler* TestHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args)
|
||||||
|
{
|
||||||
|
if(args.size() < 1 )
|
||||||
|
{
|
||||||
|
this->SetError("called with incorrect number of arguments");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<std::string>::const_iterator it;
|
||||||
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||||
|
for ( it = args.begin(); it != args.end(); ++ it )
|
||||||
|
{
|
||||||
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||||
|
std::string fname = cwd;
|
||||||
|
fname += "/";
|
||||||
|
fname += *it;
|
||||||
|
|
||||||
|
if ( !cmSystemTools::FileExists(fname.c_str()) )
|
||||||
|
{
|
||||||
|
// No subdirectory? So what...
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cmSystemTools::ChangeDirectory(fname.c_str());
|
||||||
|
const char* testFilename;
|
||||||
|
if( cmSystemTools::FileExists("CTestTestfile.cmake") )
|
||||||
|
{
|
||||||
|
// does the CTestTestfile.cmake exist ?
|
||||||
|
testFilename = "CTestTestfile.cmake";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No CTestTestfile? Who cares...
|
||||||
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fname += "/";
|
||||||
|
fname += testFilename;
|
||||||
|
bool readit =
|
||||||
|
this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),
|
||||||
|
fname.c_str());
|
||||||
|
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||||
|
if(!readit)
|
||||||
|
{
|
||||||
|
std::string m = "Could not find include file: ";
|
||||||
|
m += fname;
|
||||||
|
this->SetError(m.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
class cmCTestAddSubdirectoryCommand : public cmCommand
|
class cmCTestAddSubdirectoryCommand : public cmCommand
|
||||||
{
|
{
|
||||||
@ -1258,18 +1344,24 @@ void cmCTestTestHandler::GetListOfTests()
|
|||||||
newCom1->TestHandler = this;
|
newCom1->TestHandler = this;
|
||||||
cm.AddCommand(newCom1);
|
cm.AddCommand(newCom1);
|
||||||
|
|
||||||
// Add handler for ADD_SUBDIRECTORY
|
// Add handler for SUBDIRS
|
||||||
cmCTestAddSubdirectoryCommand* newCom2 =
|
cmCTestSubdirCommand* newCom2 =
|
||||||
new cmCTestAddSubdirectoryCommand;
|
new cmCTestSubdirCommand;
|
||||||
newCom2->TestHandler = this;
|
newCom2->TestHandler = this;
|
||||||
cm.AddCommand(newCom2);
|
cm.AddCommand(newCom2);
|
||||||
|
|
||||||
// Add handler for SET_SOURCE_FILES_PROPERTIES
|
// Add handler for ADD_SUBDIRECTORY
|
||||||
cmCTestSetTestsPropertiesCommand* newCom3
|
cmCTestAddSubdirectoryCommand* newCom3 =
|
||||||
= new cmCTestSetTestsPropertiesCommand;
|
new cmCTestAddSubdirectoryCommand;
|
||||||
newCom3->TestHandler = this;
|
newCom3->TestHandler = this;
|
||||||
cm.AddCommand(newCom3);
|
cm.AddCommand(newCom3);
|
||||||
|
|
||||||
|
// Add handler for SET_SOURCE_FILES_PROPERTIES
|
||||||
|
cmCTestSetTestsPropertiesCommand* newCom4
|
||||||
|
= new cmCTestSetTestsPropertiesCommand;
|
||||||
|
newCom4->TestHandler = this;
|
||||||
|
cm.AddCommand(newCom4);
|
||||||
|
|
||||||
const char* testFilename;
|
const char* testFilename;
|
||||||
if( cmSystemTools::FileExists("CTestTestfile.cmake") )
|
if( cmSystemTools::FileExists("CTestTestfile.cmake") )
|
||||||
{
|
{
|
||||||
|
@ -275,11 +275,7 @@ void cmLocalGenerator::GenerateTestFiles()
|
|||||||
size_t i;
|
size_t i;
|
||||||
for(i = 0; i < this->Children.size(); ++i)
|
for(i = 0; i < this->Children.size(); ++i)
|
||||||
{
|
{
|
||||||
fout << "ADD_SUBDIRECTORY(";
|
fout << "SUBDIRS(";
|
||||||
std::string srcP =
|
|
||||||
this->Children[i]->GetMakefile()->GetStartDirectory();
|
|
||||||
fout << this->Convert(srcP.c_str(),START);
|
|
||||||
fout << " ";
|
|
||||||
std::string outP =
|
std::string outP =
|
||||||
this->Children[i]->GetMakefile()->GetStartOutputDirectory();
|
this->Children[i]->GetMakefile()->GetStartOutputDirectory();
|
||||||
fout << this->Convert(outP.c_str(),START_OUTPUT);
|
fout << this->Convert(outP.c_str(),START_OUTPUT);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user