cmMakefile: Extract CompileFeaturesAvailable method.

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

View File

@ -5011,37 +5011,14 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
return false; return false;
} }
const char* featuresKnown = const char* features = this->CompileFeaturesAvailable(lang, error);
this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES"); if (!features)
if (!featuresKnown || !*featuresKnown)
{ {
cmOStringStream e;
if (error)
{
e << "no";
}
else
{
e << "No";
}
e << " known features for " << lang << " compiler\n\""
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
<< "\"\nversion "
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
if (error)
{
*error = e.str();
}
else
{
this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
return false; return false;
} }
std::vector<std::string> availableFeatures; std::vector<std::string> availableFeatures;
cmSystemTools::ExpandListArgument(featuresKnown, availableFeatures); cmSystemTools::ExpandListArgument(features, availableFeatures);
if (std::find(availableFeatures.begin(), if (std::find(availableFeatures.begin(),
availableFeatures.end(), availableFeatures.end(),
feature) == availableFeatures.end()) feature) == availableFeatures.end())
@ -5108,6 +5085,41 @@ CompileFeatureKnown(cmTarget const* target, const std::string& feature,
return false; return false;
} }
//----------------------------------------------------------------------------
const char* cmMakefile::
CompileFeaturesAvailable(const std::string& lang, std::string *error) const
{
const char* featuresKnown =
this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
if (!featuresKnown || !*featuresKnown)
{
cmOStringStream e;
if (error)
{
e << "no";
}
else
{
e << "No";
}
e << " known features for " << lang << " compiler\n\""
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
<< "\"\nversion "
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
if (error)
{
*error = e.str();
}
else
{
this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
return 0;
}
return featuresKnown;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile:: bool cmMakefile::
AddRequiredTargetCxxFeature(cmTarget *target, AddRequiredTargetCxxFeature(cmTarget *target,

View File

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