diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmSetPropertiesCommand.cxx | 17 | ||||
-rw-r--r-- | Source/cmSetPropertiesCommand.h | 2 | ||||
-rw-r--r-- | Source/cmSetTestsPropertiesCommand.cxx | 69 | ||||
-rw-r--r-- | Source/cmSetTestsPropertiesCommand.h | 5 |
4 files changed, 69 insertions, 24 deletions
diff --git a/Source/cmSetPropertiesCommand.cxx b/Source/cmSetPropertiesCommand.cxx index 0a0993e..d69dddd 100644 --- a/Source/cmSetPropertiesCommand.cxx +++ b/Source/cmSetPropertiesCommand.cxx @@ -16,6 +16,7 @@ =========================================================================*/ #include "cmSetPropertiesCommand.h" #include "cmSetTargetPropertiesCommand.h" +#include "cmSetTestsPropertiesCommand.h" // cmSetPropertiesCommand bool cmSetPropertiesCommand::InitialPass( @@ -87,6 +88,11 @@ bool cmSetPropertiesCommand::InitialPass( scope = cmProperty::TARGET; scopeName = args[1].c_str(); } + else if (args[0] == "TEST" && numFiles == 2) + { + scope = cmProperty::TEST; + scopeName = args[1].c_str(); + } else { this->SetError("called with illegal arguments."); @@ -133,6 +139,17 @@ bool cmSetPropertiesCommand::InitialPass( } break; 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: // not implemented yet break; diff --git a/Source/cmSetPropertiesCommand.h b/Source/cmSetPropertiesCommand.h index 78ee815..b949e36 100644 --- a/Source/cmSetPropertiesCommand.h +++ b/Source/cmSetPropertiesCommand.h @@ -56,7 +56,7 @@ public: " PROPERTIES prop1 value1\n" " prop2 value2 ...)\n" "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." ; } diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index f1f571a..8e02ada 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -74,38 +74,61 @@ bool cmSetTestsPropertiesCommand::InitialPass( return false; } + std::vector<cmTest*> &tests = *this->Makefile->GetTests(); // now loop over all the targets int i; - unsigned int k; for(i = 0; i < numFiles; ++i) { - bool found = false; - // if the file is already in the makefile just set properites on it - std::vector<cmTest*>::iterator it; - for ( it = tests.begin(); it != tests.end(); ++ it ) + std::string errors; + bool ret = + cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(), + propertyPairs, + this->Makefile, errors); + if (!ret) { - cmTest* test = *it; - if ( test->GetName() == args[i] ) - { - // now loop through all the props and set them - for (k = 0; k < propertyPairs.size(); k = k + 2) - { - test->SetProperty(propertyPairs[k].c_str(), - propertyPairs[k+1].c_str()); - } - found = true; - break; - } + this->SetError(errors.c_str()); + return ret; } + } + + return true; +} + - // if file is not already in the makefile, then add it - if ( ! found ) - { - std::string message = "Can not find test to add properties to: "; - message += args[i]; - this->SetError(message.c_str()); +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; + // if the file is already in the makefile just set properites on it + std::vector<cmTest*>::iterator it; + for ( it = tests.begin(); it != tests.end(); ++ it ) + { + cmTest* test = *it; + if ( test->GetName() == tname ) + { + // now loop through all the props and set them + for (k = 0; k < propertyPairs.size(); k = k + 2) + { + test->SetProperty(propertyPairs[k].c_str(), + propertyPairs[k+1].c_str()); + } + found = true; + break; } + } + + // if file is not already in the makefile, then add it + if ( ! found ) + { + errors = "Can not find test to add properties to: "; + errors += tname; + return false; } return true; diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index d01d622..16b5188 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -71,6 +71,11 @@ public: } cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); + + static bool SetOneTest(const char *tname, + std::vector<std::string> &propertyPairs, + cmMakefile *mf, + std::string &errors); }; |