diff --git a/Source/cmSetPropertiesCommand.cxx b/Source/cmSetPropertiesCommand.cxx index 0a0993e53..d69ddddce 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 78ee8151a..b949e36ca 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 f1f571a39..8e02adae8 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -74,38 +74,61 @@ bool cmSetTestsPropertiesCommand::InitialPass( return false; } + std::vector &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::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; } + } - // 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()); + return true; +} + + +bool cmSetTestsPropertiesCommand +::SetOneTest(const char *tname, + std::vector &propertyPairs, + cmMakefile *mf, std::string &errors) +{ + std::vector &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::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 d01d62243..16b518866 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 &propertyPairs, + cmMakefile *mf, + std::string &errors); };