[cmake-commits] martink committed cmSetPropertiesCommand.cxx 1.3 1.4 cmSetPropertiesCommand.h 1.1 1.2 cmSetTestsPropertiesCommand.cxx 1.3 1.4 cmSetTestsPropertiesCommand.h 1.5 1.6

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Dec 7 14:54:17 EST 2006


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv23627/Source

Modified Files:
	cmSetPropertiesCommand.cxx cmSetPropertiesCommand.h 
	cmSetTestsPropertiesCommand.cxx cmSetTestsPropertiesCommand.h 
Log Message:
ENH: implements SetProperties for TEST


Index: cmSetTestsPropertiesCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetTestsPropertiesCommand.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmSetTestsPropertiesCommand.h	12 May 2006 17:53:21 -0000	1.5
+++ cmSetTestsPropertiesCommand.h	7 Dec 2006 19:54:15 -0000	1.6
@@ -71,6 +71,11 @@
     }
 
   cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
+
+  static bool SetOneTest(const char *tname, 
+                         std::vector<std::string> &propertyPairs,
+                         cmMakefile *mf,
+                         std::string &errors);
 };
 
 

Index: cmSetTestsPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetTestsPropertiesCommand.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cmSetTestsPropertiesCommand.cxx	12 May 2006 17:53:21 -0000	1.3
+++ cmSetTestsPropertiesCommand.cxx	7 Dec 2006 19:54:15 -0000	1.4
@@ -74,38 +74,61 @@
     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;
       }
+    }
 
-    // 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<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;

Index: cmSetPropertiesCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertiesCommand.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmSetPropertiesCommand.h	1 Dec 2006 18:35:21 -0000	1.1
+++ cmSetPropertiesCommand.h	7 Dec 2006 19:54:15 -0000	1.2
@@ -56,7 +56,7 @@
         "                 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."
         ;
     }
   

Index: cmSetPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertiesCommand.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cmSetPropertiesCommand.cxx	7 Dec 2006 15:33:35 -0000	1.3
+++ cmSetPropertiesCommand.cxx	7 Dec 2006 19:54:14 -0000	1.4
@@ -16,6 +16,7 @@
 =========================================================================*/
 #include "cmSetPropertiesCommand.h"
 #include "cmSetTargetPropertiesCommand.h"
+#include "cmSetTestsPropertiesCommand.h"
 
 // cmSetPropertiesCommand
 bool cmSetPropertiesCommand::InitialPass(
@@ -87,6 +88,11 @@
     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 @@
       }
       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;



More information about the Cmake-commits mailing list