summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-02-06 12:18:10 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-02-07 15:21:08 (GMT)
commit92e98dd909bd399f508ff7c2f9657095ddc766cc (patch)
tree37cdba7d39615395842c1a1a0dffb84f1b68fc68 /Source
parent1714c27a74c1616e5998a1a51fe42848a1f1c389 (diff)
downloadCMake-92e98dd909bd399f508ff7c2f9657095ddc766cc.zip
CMake-92e98dd909bd399f508ff7c2f9657095ddc766cc.tar.gz
CMake-92e98dd909bd399f508ff7c2f9657095ddc766cc.tar.bz2
Deduplicate the isGeneratorExpression method.
This API seems like the most appropriate.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportFileGenerator.cxx10
-rw-r--r--Source/cmGeneratorExpression.cxx13
-rw-r--r--Source/cmGeneratorExpression.h2
-rw-r--r--Source/cmTarget.cxx10
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx10
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx10
6 files changed, 19 insertions, 36 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 7e4c3df..fbed95a 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -315,14 +315,6 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input,
}
//----------------------------------------------------------------------------
-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(
std::string &input,
@@ -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);
}
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 7add1bf..c9f784b 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/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;
+}
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 700fe03..d487919 100644
--- a/Source/cmGeneratorExpression.h
+++ b/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 &);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ca0e24b..2eaf1c1 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2270,14 +2270,6 @@ static std::string targetNameGenex(const char *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,
LinkLibraryType llt)
@@ -2300,7 +2292,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
llt).c_str());
}
- if (isGeneratorExpression(lib))
+ if (cmGeneratorExpression::Find(lib) != std::string::npos)
{
return;
}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index eaacfa9..808806a 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -41,14 +41,6 @@ void cmTargetIncludeDirectoriesCommand
}
//----------------------------------------------------------------------------
-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;
}
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index cb913f5..fab3306 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -265,19 +265,11 @@ static std::string compileProperty(cmTarget *tgt, const std::string &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
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_.:-]+$");