diff options
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 35d716c..85c2345 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -32,6 +32,7 @@ #include "cmLocalGenerator.h" #include "cmMSVC60LinkLineComputer.h" #include "cmMakefile.h" +#include "cmMessageType.h" #include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmSourceFile.h" @@ -137,7 +138,7 @@ bool cmGlobalGenerator::SetGeneratorInstance(std::string const& i, " " << i << "\n" "was specified."; /* clang-format on */ - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } @@ -157,7 +158,7 @@ bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p, " " << p << "\n" "was specified."; /* clang-format on */ - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } @@ -176,7 +177,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts, " " << ts << "\n" "was specified."; /* clang-format on */ - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } @@ -319,8 +320,8 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const if (srcs.empty()) { std::ostringstream e; e << "No SOURCES given to target: " << target->GetName(); - this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(), - target->GetBacktrace()); + this->GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, e.str(), target->GetBacktrace()); failed = true; } } @@ -454,7 +455,7 @@ void cmGlobalGenerator::EnableLanguage( e << "Language '" << li << "' is currently being enabled. " "Recursive call not allowed."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); return; } @@ -471,7 +472,7 @@ void cmGlobalGenerator::EnableLanguage( std::ostringstream e; e << "The test project needs language " << lang << " which is not enabled."; - this->TryCompileOuterMakefile->IssueMessage(cmake::FATAL_ERROR, + this->TryCompileOuterMakefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); return; @@ -775,7 +776,7 @@ void cmGlobalGenerator::EnableLanguage( if (!this->CMakeInstance->GetIsInTryCompile()) { this->PrintCompilerAdvice(noCompiler, lang, mf->GetDefinition(compilerEnv)); - mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str()); + mf->IssueMessage(MessageType::FATAL_ERROR, noCompiler.str()); fatalError = true; } } @@ -903,7 +904,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility( " compiler id \"AppleClang\" to \"Clang\" for compatibility." ; /* clang-format on */ - mf->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); } CM_FALLTHROUGH; case cmPolicies::OLD: @@ -913,7 +914,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility( case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: mf->IssueMessage( - cmake::FATAL_ERROR, + MessageType::FATAL_ERROR, cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0025)); case cmPolicies::NEW: // NEW behavior is to keep AppleClang. @@ -933,7 +934,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility( " compiler id \"QCC\" to \"GNU\" for compatibility." ; /* clang-format on */ - mf->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); } CM_FALLTHROUGH; case cmPolicies::OLD: @@ -948,7 +949,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility( case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: mf->IssueMessage( - cmake::FATAL_ERROR, + MessageType::FATAL_ERROR, cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0047)); CM_FALLTHROUGH; case cmPolicies::NEW: @@ -1410,13 +1411,13 @@ void cmGlobalGenerator::Generate() if (!this->GenerateCPackPropertiesFile()) { this->GetCMakeInstance()->IssueMessage( - cmake::FATAL_ERROR, "Could not write CPack properties file."); + MessageType::FATAL_ERROR, "Could not write CPack properties file."); } for (auto& buildExpSet : this->BuildExportSets) { if (!buildExpSet.second->GenerateImportFile()) { if (!cmSystemTools::GetErrorOccuredFlag()) { - this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, "Could not write export file."); } return; @@ -1439,7 +1440,8 @@ void cmGlobalGenerator::Generate() for (std::string const& t : this->CMP0042WarnTargets) { w << " " << t << "\n"; } - this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING, + w.str()); } if (!this->CMP0068WarnTargets.empty()) { @@ -1455,7 +1457,8 @@ void cmGlobalGenerator::Generate() for (std::string const& t : this->CMP0068WarnTargets) { w << " " << t << "\n"; } - this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING, + w.str()); } this->CMakeInstance->UpdateProgress("Generating done", -1); @@ -2233,7 +2236,7 @@ bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName, if (!tgt) { return true; } - cmake::MessageType messageType = cmake::AUTHOR_WARNING; + MessageType messageType = MessageType::AUTHOR_WARNING; std::ostringstream e; bool issueMessage = false; switch (tgt->GetPolicyStatusCMP0037()) { @@ -2247,18 +2250,18 @@ bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName, case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: issueMessage = true; - messageType = cmake::FATAL_ERROR; + messageType = MessageType::FATAL_ERROR; break; } if (issueMessage) { e << "The target name \"" << targetName << "\" is reserved " << reason << "."; - if (messageType == cmake::AUTHOR_WARNING) { + if (messageType == MessageType::AUTHOR_WARNING) { e << " It may result in undefined behavior."; } this->GetCMakeInstance()->IssueMessage(messageType, e.str(), tgt->GetBacktrace()); - if (messageType == cmake::FATAL_ERROR) { + if (messageType == MessageType::FATAL_ERROR) { return false; } } @@ -2453,7 +2456,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES"); if (this->InstallTargetEnabled && skipInstallRules) { this->CMakeInstance->IssueMessage( - cmake::WARNING, + MessageType::WARNING, "CMAKE_SKIP_INSTALL_RULES was enabled even though " "installation rules have been specified", mf->GetBacktrace()); @@ -3023,11 +3026,23 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) std::string cmGlobalGenerator::EscapeJSON(const std::string& s) { std::string result; + result.reserve(s.size()); for (char i : s) { - if (i == '"' || i == '\\') { - result += '\\'; + switch (i) { + case '"': + case '\\': + result += '\\'; + result += i; + break; + case '\n': + result += "\\n"; + break; + case '\t': + result += "\\t"; + break; + default: + result += i; } - result += i; } return result; } |