summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-05-15 09:33:20 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-05-20 14:11:34 (GMT)
commit6b9b2fff61777b7d18f6c550119103dd3357d6c4 (patch)
tree13e9769a9174c46808df7b0a4889a22dd3cb6fe9 /Source
parent2d5e3d2d2bfd79311c40db173d13f6d0cfb10019 (diff)
downloadCMake-6b9b2fff61777b7d18f6c550119103dd3357d6c4.zip
CMake-6b9b2fff61777b7d18f6c550119103dd3357d6c4.tar.gz
CMake-6b9b2fff61777b7d18f6c550119103dd3357d6c4.tar.bz2
cmMakefile: Extract CompileFeatureKnown method.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx78
-rw-r--r--Source/cmMakefile.h3
2 files changed, 52 insertions, 29 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 42dedc9..1905489 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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,13 +5058,58 @@ 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,
const std::string& feature) const
{
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 90e2e19..1a7bf20 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -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);