ENH: implements SetProperties for TEST
This commit is contained in:
parent
013ec39881
commit
a00200e8d4
|
@ -16,6 +16,7 @@
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
#include "cmSetPropertiesCommand.h"
|
#include "cmSetPropertiesCommand.h"
|
||||||
#include "cmSetTargetPropertiesCommand.h"
|
#include "cmSetTargetPropertiesCommand.h"
|
||||||
|
#include "cmSetTestsPropertiesCommand.h"
|
||||||
|
|
||||||
// cmSetPropertiesCommand
|
// cmSetPropertiesCommand
|
||||||
bool cmSetPropertiesCommand::InitialPass(
|
bool cmSetPropertiesCommand::InitialPass(
|
||||||
|
@ -87,6 +88,11 @@ bool cmSetPropertiesCommand::InitialPass(
|
||||||
scope = cmProperty::TARGET;
|
scope = cmProperty::TARGET;
|
||||||
scopeName = args[1].c_str();
|
scopeName = args[1].c_str();
|
||||||
}
|
}
|
||||||
|
else if (args[0] == "TEST" && numFiles == 2)
|
||||||
|
{
|
||||||
|
scope = cmProperty::TEST;
|
||||||
|
scopeName = args[1].c_str();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->SetError("called with illegal arguments.");
|
this->SetError("called with illegal arguments.");
|
||||||
|
@ -133,6 +139,17 @@ bool cmSetPropertiesCommand::InitialPass(
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cmProperty::TEST:
|
case cmProperty::TEST:
|
||||||
|
{
|
||||||
|
std::string errors;
|
||||||
|
bool ret = cmSetTestsPropertiesCommand::
|
||||||
|
SetOneTest(scopeName,propertyPairs, this->Makefile, errors);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
this->SetError(errors.c_str());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case cmProperty::SOURCE_FILE:
|
case cmProperty::SOURCE_FILE:
|
||||||
// not implemented yet
|
// not implemented yet
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
" PROPERTIES prop1 value1\n"
|
" PROPERTIES prop1 value1\n"
|
||||||
" prop2 value2 ...)\n"
|
" prop2 value2 ...)\n"
|
||||||
"Set properties on something. The scope_value is either GLOBAL "
|
"Set properties on something. The scope_value is either GLOBAL "
|
||||||
"DIRECTORY dir_name> or TARGET tgt_name."
|
"DIRECTORY dir_name, TARGET tgt_name, or TEST test_name."
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,19 +74,43 @@ bool cmSetTestsPropertiesCommand::InitialPass(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<cmTest*> &tests = *this->Makefile->GetTests();
|
std::vector<cmTest*> &tests = *this->Makefile->GetTests();
|
||||||
// now loop over all the targets
|
// now loop over all the targets
|
||||||
int i;
|
int i;
|
||||||
unsigned int k;
|
|
||||||
for(i = 0; i < numFiles; ++i)
|
for(i = 0; i < numFiles; ++i)
|
||||||
{
|
{
|
||||||
|
std::string errors;
|
||||||
|
bool ret =
|
||||||
|
cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(),
|
||||||
|
propertyPairs,
|
||||||
|
this->Makefile, errors);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
this->SetError(errors.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool cmSetTestsPropertiesCommand
|
||||||
|
::SetOneTest(const char *tname,
|
||||||
|
std::vector<std::string> &propertyPairs,
|
||||||
|
cmMakefile *mf, std::string &errors)
|
||||||
|
{
|
||||||
|
std::vector<cmTest*> &tests = *mf->GetTests();
|
||||||
|
// now loop over all the targets
|
||||||
|
unsigned int k;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
// if the file is already in the makefile just set properites on it
|
// if the file is already in the makefile just set properites on it
|
||||||
std::vector<cmTest*>::iterator it;
|
std::vector<cmTest*>::iterator it;
|
||||||
for ( it = tests.begin(); it != tests.end(); ++ it )
|
for ( it = tests.begin(); it != tests.end(); ++ it )
|
||||||
{
|
{
|
||||||
cmTest* test = *it;
|
cmTest* test = *it;
|
||||||
if ( test->GetName() == args[i] )
|
if ( test->GetName() == tname )
|
||||||
{
|
{
|
||||||
// now loop through all the props and set them
|
// now loop through all the props and set them
|
||||||
for (k = 0; k < propertyPairs.size(); k = k + 2)
|
for (k = 0; k < propertyPairs.size(); k = k + 2)
|
||||||
|
@ -102,10 +126,9 @@ bool cmSetTestsPropertiesCommand::InitialPass(
|
||||||
// if file is not already in the makefile, then add it
|
// if file is not already in the makefile, then add it
|
||||||
if ( ! found )
|
if ( ! found )
|
||||||
{
|
{
|
||||||
std::string message = "Can not find test to add properties to: ";
|
errors = "Can not find test to add properties to: ";
|
||||||
message += args[i];
|
errors += tname;
|
||||||
this->SetError(message.c_str());
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -71,6 +71,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
|
cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
|
||||||
|
|
||||||
|
static bool SetOneTest(const char *tname,
|
||||||
|
std::vector<std::string> &propertyPairs,
|
||||||
|
cmMakefile *mf,
|
||||||
|
std::string &errors);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue