1
0
Эх сурвалжийг харах

ENH: add suport for semi-colon separated list variables

Bill Hoffman 23 жил өмнө
parent
commit
8aa3c35dad

+ 4 - 2
Source/cmLinkLibrariesCommand.cxx

@@ -17,13 +17,15 @@
 #include "cmLinkLibrariesCommand.h"
 
 // cmLinkLibrariesCommand
-bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
+bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& argsIn)
 {
-  if(args.size() < 1 )
+  if(argsIn.size() < 1 )
     {
     this->SetError("called with incorrect number of arguments");
     return false;
     }
+  std::vector<std::string> args;
+  cmSystemTools::ExpandListArguments(argsIn, args);
   // add libraries, nothe that there is an optional prefix 
   // of debug and optimized than can be used
   for(std::vector<std::string>::const_iterator i = args.begin();

+ 19 - 12
Source/cmMSDotNETGenerator.cxx

@@ -40,20 +40,27 @@ void cmMSDotNETGenerator::GenerateMakefile()
   while(endpos != std::string::npos)
     {
     endpos = configTypes.find(' ', start);
+    std::string config;
+    std::string::size_type len;
     if(endpos != std::string::npos)
       {
-      std::string config = configTypes.substr(start, endpos - start);
-      if(config == "Debug" || config == "Release" ||
-         config == "MinSizeRel" || config == "RelWithDebInfo")
-        {
-        m_Configurations.push_back(config);
-        }
-      else
-        {
-        cmSystemTools::Error("Invalid configuration type in CMAKE_CONFIGURATION_TYPES: ",
-                             config.c_str(),
-                             " (Valid types are Debug,Release,MinSizeRel,RelWithDebInfo)");
-        }
+      len = endpos - start;
+      }
+    else
+      {
+      len = configTypes.size() - start;
+      }
+    config = configTypes.substr(start, len);
+    if(config == "Debug" || config == "Release" ||
+       config == "MinSizeRel" || config == "RelWithDebInfo")
+      {
+      m_Configurations.push_back(config);
+      }
+    else
+      {
+      cmSystemTools::Error("Invalid configuration type in CMAKE_CONFIGURATION_TYPES: ",
+                           config.c_str(),
+                           " (Valid types are Debug,Release,MinSizeRel,RelWithDebInfo)");
       }
     start = endpos+1;
     }

+ 34 - 0
Source/cmSystemTools.cxx

@@ -1474,3 +1474,37 @@ void cmSystemTools::GlobDirs(const char *fullPath,
       }
     }
 }
+
+
+void cmSystemTools::ExpandListArguments(std::vector<std::string> const& arguments, 
+                                        std::vector<std::string>& newargs)
+{
+  std::vector<std::string>::const_iterator i;
+  for(i = arguments.begin();i != arguments.end(); ++i)
+    {
+    if(i->find(';') != std::string::npos)
+      {
+      std::string::size_type start = 0;
+      std::string::size_type endpos = 0;
+      while(endpos != std::string::npos)
+        {
+        endpos = i->find(';', start); 
+        std::string::size_type len;
+        if(endpos != std::string::npos)
+          {
+          len = endpos - start;
+          }
+        else
+          {
+          len = i->size()-start;
+          }
+        newargs.push_back(i->substr(start, len));
+        start = endpos+1;
+        }
+      }
+    else
+      {
+      newargs.push_back(*i);
+      }
+    }
+}

+ 7 - 0
Source/cmSystemTools.h

@@ -43,6 +43,13 @@ public:
                             const char* replace,
                             const char* with);
 
+  /** Expand out any arguements in the vector that have ; separated
+   *  strings into multiple arguements.  A new vector is created 
+   *  containing the expanded versions of all arguments in argsIn.
+   */
+  static void ExpandListArguments(std::vector<std::string> const& argsIn,
+                                  std::vector<std::string>& argsOut);
+
   /**
    * Look for and replace registry values in a string
    */

+ 4 - 2
Source/cmTargetLinkLibrariesCommand.cxx

@@ -17,13 +17,15 @@
 #include "cmTargetLinkLibrariesCommand.h"
 
 // cmTargetLinkLibrariesCommand
-bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
+bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& argsIn)
 {
-  if(args.size() < 2)
+  if(argsIn.size() < 2)
     {
     this->SetError("called with incorrect number of arguments");
     return false;
     }
+  std::vector<std::string> args;
+  cmSystemTools::ExpandListArguments(argsIn, args);
   // add libraries, nothe that there is an optional prefix 
   // of debug and optimized than can be used
   std::vector<std::string>::const_iterator i = args.begin();