From 72537e4436a17535af5424628adef3b614a61679 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 4 Feb 2015 23:26:11 +0100 Subject: [PATCH] Features: Add dialect compile flags only if default is known. The CMAKE__STANDARD_DEFAULT variable indicates whether the compiler has any notion of standard levels and that CMake knows about them. If no language standard levels are available, skip all logic to attempt to add a flag for the level. Also fail with an internal error if a bad default value is set. --- Source/cmLocalGenerator.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index af4c95040..81e37f626 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2209,7 +2209,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target, } const char* defaultStd = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT"); - if (defaultStd && !*defaultStd) + if (!defaultStd || !*defaultStd) { // This compiler has no notion of language standard levels. return; @@ -2276,15 +2276,15 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target, std::find(stds.begin(), stds.end(), standard); assert(stdIt != stds.end()); - std::vector::const_iterator defaultStdIt; - if (defaultStd) + std::vector::const_iterator defaultStdIt = + std::find(stds.begin(), stds.end(), defaultStd); + if (defaultStdIt == stds.end()) { - defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd); - assert(defaultStdIt != stds.end()); - } - else - { - defaultStdIt = stds.end() - 1; + std::string e = + "CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" + + std::string(defaultStd) + "'"; + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, e); + return; } for ( ; stdIt <= defaultStdIt; ++stdIt)