Browse Source

Fix help string when NAMES was used

Sebastien Barre 24 năm trước cách đây
mục cha
commit
fb35c19d30
1 tập tin đã thay đổi với 29 bổ sung28 xóa
  1. 29 28
      Source/cmFindLibraryCommand.cxx

+ 29 - 28
Source/cmFindLibraryCommand.cxx

@@ -49,34 +49,7 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
     this->SetError("called with incorrect number of arguments");
     this->SetError("called with incorrect number of arguments");
     return false;
     return false;
     }
     }
-  // Now check and see if the value has been stored in the cache
-  // already, if so use that value and don't look for the program
-  std::string helpString = "Where can the ";
-  if(args[1] == "NAMES")
-    {
-    for(unsigned int i=2; (args[i] != "PATHS" && i < args.size()); ++i)
-      {
-      helpString = "( ";
-      helpString +=  args[i];
-      helpString +=  " ";
-      }
-    }
-  else
-    {
-    helpString += args[1];
-    }
-  helpString += " library be found";
-  const char* cacheValue
-    = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
-  if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
-    { 
-    m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
-    cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
-                                                 cacheValue,
-                                                 helpString.c_str(),
-                                                 cmCacheManager::FILEPATH);
-    return true;
-    }
+
   std::vector<std::string> path;
   std::vector<std::string> path;
   std::vector<std::string> names;
   std::vector<std::string> names;
   bool foundName = false;
   bool foundName = false;
@@ -124,6 +97,34 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
       path.push_back(exp);
       path.push_back(exp);
       }
       }
     }
     }
+
+  std::string helpString = "Where can ";
+  if (names.size() == 1)
+    {
+    helpString += "the " + names[0] + " library be found";
+    }
+  else
+    {
+    helpString += "one of the " + names[0];
+    for (unsigned int j = 1; j < names.size() - 1; ++j)
+      {
+      helpString += ", " + names[j];
+      }
+    helpString += " or " + names[names.size() - 1] + " libraries be found";
+    }
+
+  const char* cacheValue
+    = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
+  if(cacheValue && strcmp(cacheValue, "NOTFOUND"))
+    { 
+    m_Makefile->AddDefinition(args[0].c_str(), cacheValue);
+    cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
+                                                 cacheValue,
+                                                 helpString.c_str(),
+                                                 cmCacheManager::FILEPATH);
+    return true;
+    }
+
   std::string library;
   std::string library;
   for(std::vector<std::string>::iterator i = names.begin();
   for(std::vector<std::string>::iterator i = names.begin();
       i != names.end() ; ++i)
       i != names.end() ; ++i)