Deduplicate the isGeneratorExpression method.

This API seems like the most appropriate.
This commit is contained in:
Stephen Kelly 2013-02-06 13:18:10 +01:00
parent 1714c27a74
commit 92e98dd909
6 changed files with 19 additions and 36 deletions

View File

@ -314,14 +314,6 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input,
return true; 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 void
cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
@ -344,7 +336,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
for(std::vector<std::string>::iterator li = parts.begin(); for(std::vector<std::string>::iterator li = parts.begin();
li != parts.end(); ++li) li != parts.end(); ++li)
{ {
if (!isGeneratorExpression(*li)) if (cmGeneratorExpression::Find(*li) == std::string::npos)
{ {
this->AddTargetNamespace(*li, target, missingTargets); this->AddTargetNamespace(*li, target, missingTargets);
} }

View File

@ -365,3 +365,16 @@ std::string cmGeneratorExpression::Preprocess(const std::string &input,
assert(!"cmGeneratorExpression::Preprocess called with invalid args"); assert(!"cmGeneratorExpression::Preprocess called with invalid args");
return std::string(); 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;
}

View File

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

View File

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

View File

@ -40,14 +40,6 @@ void cmTargetIncludeDirectoriesCommand
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); 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 std::string cmTargetIncludeDirectoriesCommand
::Join(const std::vector<std::string> &content) ::Join(const std::vector<std::string> &content)
@ -59,7 +51,7 @@ std::string cmTargetIncludeDirectoriesCommand
it != content.end(); ++it) it != content.end(); ++it)
{ {
if (cmSystemTools::FileIsFullPath(it->c_str()) if (cmSystemTools::FileIsFullPath(it->c_str())
|| isGeneratorExpression(*it)) || cmGeneratorExpression::Find(*it) != std::string::npos)
{ {
dirs += sep + *it; dirs += sep + *it;
} }

View File

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