Browse Source

Deduplicate the isGeneratorExpression method.

This API seems like the most appropriate.
Stephen Kelly 13 years ago
parent
commit
92e98dd909

+ 1 - 9
Source/cmExportFileGenerator.cxx

@@ -314,14 +314,6 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input,
   return true;
 }
 
-//----------------------------------------------------------------------------
-static bool isGeneratorExpression(const std::string &lib)
-{
-  const std::string::size_type openpos = lib.find("$<");
-  return (openpos != std::string::npos)
-      && (lib.find(">", openpos) != std::string::npos);
-}
-
 //----------------------------------------------------------------------------
 void
 cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
@@ -344,7 +336,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
   for(std::vector<std::string>::iterator li = parts.begin();
       li != parts.end(); ++li)
     {
-    if (!isGeneratorExpression(*li))
+    if (cmGeneratorExpression::Find(*li) == std::string::npos)
       {
       this->AddTargetNamespace(*li, target, missingTargets);
       }

+ 13 - 0
Source/cmGeneratorExpression.cxx

@@ -365,3 +365,16 @@ std::string cmGeneratorExpression::Preprocess(const std::string &input,
   assert(!"cmGeneratorExpression::Preprocess called with invalid args");
   return std::string();
 }
+
+//----------------------------------------------------------------------------
+std::string::size_type cmGeneratorExpression::Find(const std::string &input)
+{
+  const std::string::size_type openpos = input.find("$<");
+  if (openpos != std::string::npos
+        && input.find(">", openpos) != std::string::npos)
+      {
+      return openpos;
+      }
+    }
+  return std::string::npos;
+}

+ 2 - 0
Source/cmGeneratorExpression.h

@@ -62,6 +62,8 @@ public:
   static void Split(const std::string &input,
                     std::vector<std::string> &output);
 
+  static std::string::size_type Find(const std::string &input);
+
 private:
   cmGeneratorExpression(const cmGeneratorExpression &);
   void operator=(const cmGeneratorExpression &);

+ 1 - 9
Source/cmTarget.cxx

@@ -2269,14 +2269,6 @@ static std::string targetNameGenex(const char *lib)
   return std::string("$<TARGET_NAME:") + lib + ">";
 }
 
-//----------------------------------------------------------------------------
-static bool isGeneratorExpression(const std::string &lib)
-{
-  const std::string::size_type openpos = lib.find("$<");
-  return (openpos != std::string::npos)
-      && (lib.find(">", openpos) != std::string::npos);
-}
-
 //----------------------------------------------------------------------------
 void cmTarget::AddLinkLibrary(cmMakefile& mf,
                               const char *target, const char* lib,
@@ -2300,7 +2292,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
                                                           llt).c_str());
   }
 
-  if (isGeneratorExpression(lib))
+  if (cmGeneratorExpression::Find(lib) != std::string::npos)
     {
     return;
     }

+ 1 - 9
Source/cmTargetIncludeDirectoriesCommand.cxx

@@ -40,14 +40,6 @@ void cmTargetIncludeDirectoriesCommand
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
-static bool isGeneratorExpression(const std::string &lib)
-{
-  const std::string::size_type openpos = lib.find("$<");
-  return (openpos != std::string::npos)
-      && (lib.find(">", openpos) != std::string::npos);
-}
-
 //----------------------------------------------------------------------------
 std::string cmTargetIncludeDirectoriesCommand
 ::Join(const std::vector<std::string> &content)
@@ -59,7 +51,7 @@ std::string cmTargetIncludeDirectoriesCommand
     it != content.end(); ++it)
     {
     if (cmSystemTools::FileIsFullPath(it->c_str())
-        || isGeneratorExpression(*it))
+        || cmGeneratorExpression::Find(*it) != std::string::npos)
       {
       dirs += sep + *it;
       }

+ 1 - 9
Source/cmTargetLinkLibrariesCommand.cxx

@@ -264,20 +264,12 @@ static std::string compileProperty(cmTarget *tgt, const std::string &lib,
   return tgt->GetDebugGeneratorExpressions(value, llt);
 }
 
-//----------------------------------------------------------------------------
-static bool isGeneratorExpression(const std::string &lib)
-{
-  const std::string::size_type openpos = lib.find("$<");
-  return (openpos != std::string::npos)
-      && (lib.find(">", openpos) != std::string::npos);
-}
-
 //----------------------------------------------------------------------------
 void
 cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
                                             cmTarget::LinkLibraryType llt)
 {
-  const bool isGenex = isGeneratorExpression(lib);
+  const bool isGenex = cmGeneratorExpression::Find(lib) != std::string::npos;
 
   cmsys::RegularExpression targetNameValidator;
   targetNameValidator.compile("^[A-Za-z0-9_.:-]+$");