diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 7e4c3dfe5..fbed95a8b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/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::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 7add1bf39..c9f784be4 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 700fe033b..d487919e1 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -62,6 +62,8 @@ public: static void Split(const std::string &input, std::vector &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 ca0e24b53..2eaf1c129 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2269,14 +2269,6 @@ static std::string targetNameGenex(const char *lib) return std::string("$"; } -//---------------------------------------------------------------------------- -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; } diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index eaacfa9e7..808806a3a 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/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 &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 cb913f57a..fab3306cc 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/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_.:-]+$");