diff options
author | Brad King <brad.king@kitware.com> | 2016-03-07 18:31:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-03-07 18:52:38 (GMT) |
commit | 72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b (patch) | |
tree | c4011b95d6067e77f6074026d4ad9d5b381eee5b /Source/cmGlobalGenerator.cxx | |
parent | 8256d021c8324779c7269658a094848ebeafb82e (diff) | |
download | CMake-72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b.zip CMake-72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b.tar.gz CMake-72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b.tar.bz2 |
Diagnose recursive project/enable_language without crashing (#15999)
Calling `project()` or `enable_language()` from a toolchain file will
infinitely recurse since those commands load the toolchain file.
Diagnose and reject this case with an error message instead of crashing
when the stack eventually overflows.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 848028f..c628406 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -398,6 +398,21 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, return; } + std::set<std::string> cur_languages(languages.begin(), languages.end()); + for (std::set<std::string>::iterator li = cur_languages.begin(); + li != cur_languages.end(); ++li) + { + if (!this->LanguagesInProgress.insert(*li).second) + { + std::ostringstream e; + e << "Language '" << *li << "' is currently being enabled. " + "Recursive call not allowed."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return; + } + } + if(this->TryCompileOuterMakefile) { // In a try-compile we can only enable languages provided by caller. @@ -823,6 +838,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { cmSystemTools::SetFatalErrorOccured(); } + + for (std::set<std::string>::iterator li = cur_languages.begin(); + li != cur_languages.end(); ++li) + { + this->LanguagesInProgress.erase(*li); + } } //---------------------------------------------------------------------------- |