summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-02-05 14:25:14 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-02-05 14:25:14 (GMT)
commit9042c875dcbd0f4b7150e9050b60fb0d40365e45 (patch)
tree046a4e8dae32734af5d2001ad8255ee866536b5e /Source/cmLocalGenerator.cxx
parent0ae11b1fb0925a172adcc7cc3c9b804e2ece9ba7 (diff)
parentfb3487a9975ed321b48fad5c71dd655d66b68087 (diff)
downloadCMake-9042c875dcbd0f4b7150e9050b60fb0d40365e45.zip
CMake-9042c875dcbd0f4b7150e9050b60fb0d40365e45.tar.gz
CMake-9042c875dcbd0f4b7150e9050b60fb0d40365e45.tar.bz2
Merge topic 'fix-C-standard-features'
fb3487a9 Features: Fix C90 feature detection. 6027798a Features: Allow setting standard dialect below the default. 9d767810 Features: Populate CMAKE_<LANG>_STANDARD_DEFAULT only for supported compilers. 72537e44 Features: Add dialect compile flags only if default is known. 82c9d686 AppleClang: Remove redundant UNIX condition.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx30
1 files changed, 22 insertions, 8 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 290c2ca..7ca7684 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2205,7 +2205,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;
@@ -2272,18 +2272,32 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
std::find(stds.begin(), stds.end(), standard);
assert(stdIt != stds.end());
- std::vector<std::string>::const_iterator defaultStdIt;
- if (defaultStd)
+ std::vector<std::string>::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());
+ std::string e =
+ "CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" +
+ std::string(defaultStd) + "'";
+ this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, e);
+ return;
}
- else
+
+ // Greater or equal because the standards are stored in
+ // backward chronological order.
+ if (stdIt >= defaultStdIt)
{
- defaultStdIt = stds.end() - 1;
+ std::string option_flag =
+ "CMAKE_" + lang + *stdIt
+ + "_" + type + "_COMPILE_OPTION";
+
+ const char *opt =
+ target->GetMakefile()->GetRequiredDefinition(option_flag);
+ this->AppendFlagEscape(flags, opt);
+ return;
}
- for ( ; stdIt <= defaultStdIt; ++stdIt)
+ for ( ; stdIt < defaultStdIt; ++stdIt)
{
std::string option_flag =
"CMAKE_" + lang + *stdIt