cmMakefile: Extract CompileFeatureKnown method.

This commit is contained in:
Stephen Kelly 2014-05-15 11:33:20 +02:00
parent 2d5e3d2d2b
commit 6b9b2fff61
2 changed files with 52 additions and 29 deletions

View File

@ -5004,38 +5004,13 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
return true;
}
bool isCFeature = std::find_if(cmArrayBegin(C_FEATURES) + 1,
cmArrayEnd(C_FEATURES), cmStrCmp(feature))
!= cmArrayEnd(C_FEATURES);
bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1,
cmArrayEnd(CXX_FEATURES), cmStrCmp(feature))
!= cmArrayEnd(CXX_FEATURES);
if (!isCFeature && !isCxxFeature)
std::string lang;
if (!this->CompileFeatureKnown(target, feature, lang, error))
{
cmOStringStream e;
if (error)
{
e << "specified";
}
else
{
e << "Specified";
}
e << " unknown feature \"" << feature << "\" for "
"target \"" << target->GetName() << "\".";
if (error)
{
*error = e.str();
}
else
{
this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
return false;
}
std::string lang = isCFeature ? "C" : "CXX";
const char* featuresKnown =
this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
@ -5083,11 +5058,56 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
return isCFeature
return lang == "C"
? this->AddRequiredTargetCFeature(target, feature)
: this->AddRequiredTargetCxxFeature(target, feature);
}
//----------------------------------------------------------------------------
bool cmMakefile::
CompileFeatureKnown(cmTarget const* target, const std::string& feature,
std::string& lang, std::string *error) const
{
assert(cmGeneratorExpression::Find(feature) == std::string::npos);
bool isCFeature = std::find_if(cmArrayBegin(C_FEATURES) + 1,
cmArrayEnd(C_FEATURES), cmStrCmp(feature))
!= cmArrayEnd(C_FEATURES);
if (isCFeature)
{
lang = "C";
return true;
}
bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1,
cmArrayEnd(CXX_FEATURES), cmStrCmp(feature))
!= cmArrayEnd(CXX_FEATURES);
if (isCxxFeature)
{
lang = "CXX";
return true;
}
cmOStringStream e;
if (error)
{
e << "specified";
}
else
{
e << "Specified";
}
e << " unknown feature \"" << feature << "\" for "
"target \"" << target->GetName() << "\".";
if (error)
{
*error = e.str();
}
else
{
this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
return false;
}
//----------------------------------------------------------------------------
bool cmMakefile::
AddRequiredTargetCxxFeature(cmTarget *target,

View File

@ -889,6 +889,9 @@ public:
const std::string& feature,
std::string *error = 0) const;
bool CompileFeatureKnown(cmTarget const* target, const std::string& feature,
std::string& lang, std::string *error) const;
void ClearMatches();
void StoreMatches(cmsys::RegularExpression& re);