diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 67f809a9d..328706cf0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -385,6 +385,11 @@ void cmGlobalNinjaGenerator::Generate() this->WriteTargetAliases(*this->BuildFileStream); this->WriteBuiltinTargets(*this->BuildFileStream); + if (cmSystemTools::GetErrorOccuredFlag()) { + this->RulesFileStream->setstate(std::ios_base::failbit); + this->BuildFileStream->setstate(std::ios_base::failbit); + } + this->CloseRulesFileStream(); this->CloseBuildFileStream(); }