summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx11
-rw-r--r--Source/cmLocalGenerator.cxx9
-rw-r--r--Source/cmMakefile.cxx46
3 files changed, 60 insertions, 6 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 5f246f9..6692a92 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -1370,6 +1370,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{
std::vector<std::string> const& langAvailable
= availableFeatures[lit->first];
+ const char* standardDefault = context->Makefile
+ ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
for (std::vector<std::string>::const_iterator it = lit->second.begin();
it != lit->second.end(); ++it)
{
@@ -1378,6 +1380,12 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{
return "0";
}
+ if (standardDefault && !*standardDefault)
+ {
+ // This compiler has no notion of language standard levels.
+ // All features known for the language are always available.
+ continue;
+ }
if (!context->Makefile->HaveStandardAvailable(target,
lit->first, *it))
{
@@ -1386,8 +1394,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
const char* l = target->GetProperty(lit->first + "_STANDARD");
if (!l)
{
- l = context->Makefile
- ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
+ l = standardDefault;
}
assert(l);
context->MaxLanguageStandard[target][lit->first] = l;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 834f705..af4c950 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2207,6 +2207,13 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
{
return;
}
+ const char* defaultStd
+ = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
+ if (defaultStd && !*defaultStd)
+ {
+ // This compiler has no notion of language standard levels.
+ return;
+ }
std::string stdProp = lang + "_STANDARD";
const char *standardProp = target->GetProperty(stdProp);
if (!standardProp)
@@ -2269,8 +2276,6 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
std::find(stds.begin(), stds.end(), standard);
assert(stdIt != stds.end());
- const char* defaultStd
- = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
std::vector<std::string>::const_iterator defaultStdIt;
if (defaultStd)
{
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 87e62d7..ba914e1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -5253,6 +5253,27 @@ bool cmMakefile::
HaveCStandardAvailable(cmTarget const* target,
const std::string& feature) const
{
+ const char* defaultCStandard =
+ this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+ if (!defaultCStandard)
+ {
+ std::ostringstream e;
+ e << "CMAKE_C_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
+ "not fully configured for this compiler.";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ // Return true so the caller does not try to lookup the default standard.
+ return true;
+ }
+ if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
+ cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS))
+ {
+ std::ostringstream e;
+ e << "The CMAKE_C_STANDARD_DEFAULT variable contains an "
+ "invalid value: \"" << defaultCStandard << "\".";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ return false;
+ }
+
bool needC90 = false;
bool needC99 = false;
bool needC11 = false;
@@ -5262,7 +5283,7 @@ HaveCStandardAvailable(cmTarget const* target,
const char *existingCStandard = target->GetProperty("C_STANDARD");
if (!existingCStandard)
{
- existingCStandard = this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+ existingCStandard = defaultCStandard;
}
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
@@ -5331,6 +5352,27 @@ bool cmMakefile::IsLaterStandard(std::string const& lang,
bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
const std::string& feature) const
{
+ const char* defaultCxxStandard =
+ this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+ if (!defaultCxxStandard)
+ {
+ std::ostringstream e;
+ e << "CMAKE_CXX_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
+ "not fully configured for this compiler.";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ // Return true so the caller does not try to lookup the default standard.
+ return true;
+ }
+ if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp(defaultCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
+ {
+ std::ostringstream e;
+ e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an "
+ "invalid value: \"" << defaultCxxStandard << "\".";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ return false;
+ }
+
bool needCxx98 = false;
bool needCxx11 = false;
bool needCxx14 = false;
@@ -5339,7 +5381,7 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
if (!existingCxxStandard)
{
- existingCxxStandard = this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+ existingCxxStandard = defaultCxxStandard;
}
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),