summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-05-08 15:27:53 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-05-08 15:27:53 (GMT)
commit7b3def93b630ee7964b1d33b2b601e07c7797438 (patch)
tree574eca7299af0b5a5898d6aff6b83dc5aef66311 /Source/cmLocalGenerator.cxx
parent6eafe843ca632eadd896cca95c42420b48e2a9a2 (diff)
parent205215fb8a8aa950026d914377a54ae358a1c02a (diff)
downloadCMake-7b3def93b630ee7964b1d33b2b601e07c7797438.zip
CMake-7b3def93b630ee7964b1d33b2b601e07c7797438.tar.gz
CMake-7b3def93b630ee7964b1d33b2b601e07c7797438.tar.bz2
Merge topic 'decay-language-version'
205215fb cmTarget: Add CXX_STANDARD_REQUIRED to control decay. 1df2116b Features: Decay language flag if requested is not available. c4f4dac2 Project: Fix exit-on-error with compile feature tests. 5bb7ce72 Project: Use nullary form of main for compile feature tests. 64254e7a Project: Remove extern from static string in feature tests. 0d9c99bf Help: Fix order of help entries. dc7639bd Tests: Fix name of cache variable.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx66
1 files changed, 60 insertions, 6 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 209900f..7028da0 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2166,8 +2166,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
return;
}
std::string stdProp = lang + "_STANDARD";
- const char *standard = target->GetProperty(stdProp);
- if (!standard)
+ const char *standardProp = target->GetProperty(stdProp);
+ if (!standardProp)
{
return;
}
@@ -2175,12 +2175,66 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
bool ext = target->GetPropertyAsBool(extProp);
std::string type = ext ? "EXTENSION" : "STANDARD";
- std::string compile_option =
- "CMAKE_" + lang + std::string(standard)
- + "_" + type + "_COMPILE_OPTION";
- if (const char *opt = target->GetMakefile()->GetDefinition(compile_option))
+ if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED"))
{
+ std::string option_flag =
+ "CMAKE_" + lang + standardProp
+ + "_" + type + "_COMPILE_OPTION";
+
+ const char *opt = target->GetMakefile()->GetDefinition(option_flag);
+ if (!opt)
+ {
+ cmOStringStream e;
+ e << "Target \"" << target->GetName() << "\" requires the language "
+ "dialect \"" << lang << standardProp << "\" "
+ << (ext ? "(with compiler extensions)" : "") << ", but CMake "
+ "does not know the compile flags to use to enable it.";
+ this->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
this->AppendFlags(flags, opt);
+ return;
+ }
+
+ static std::map<std::string, std::vector<std::string> > langStdMap;
+ if (langStdMap.empty())
+ {
+ // Maintain sorted order, most recent first.
+ langStdMap["CXX"].push_back("11");
+ langStdMap["CXX"].push_back("98");
+ }
+
+ std::string standard(standardProp);
+
+ std::vector<std::string>& stds = langStdMap[lang];
+
+ std::vector<std::string>::const_iterator stdIt =
+ 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)
+ {
+ defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd);
+ assert(defaultStdIt != stds.end());
+ }
+ else
+ {
+ defaultStdIt = stds.end() - 1;
+ }
+
+ for ( ; stdIt <= defaultStdIt; ++stdIt)
+ {
+ std::string option_flag =
+ "CMAKE_" + lang + *stdIt
+ + "_" + type + "_COMPILE_OPTION";
+
+ if (const char *opt = target->GetMakefile()->GetDefinition(option_flag))
+ {
+ this->AppendFlags(flags, opt);
+ return;
+ }
}
}