diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d41e8e5c56..8ae21661b7 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -447,17 +447,23 @@ void cmState::AddFlowControlCommand(std::string const& name, void cmState::AddDisallowedCommand(std::string const& name, BuiltinCommand command, cmPolicies::PolicyID policy, - const char* message) + const char* message, + const char* additionalWarning) { this->AddBuiltinCommand( name, - [command, policy, message](const std::vector& args, - cmExecutionStatus& status) -> bool { + [command, policy, message, + additionalWarning](const std::vector& args, + cmExecutionStatus& status) -> bool { cmMakefile& mf = status.GetMakefile(); switch (mf.GetPolicyStatus(policy)) { - case cmPolicies::WARN: - mf.IssueMessage(MessageType::AUTHOR_WARNING, - cmPolicies::GetPolicyWarning(policy)); + case cmPolicies::WARN: { + std::string warning = cmPolicies::GetPolicyWarning(policy); + if (additionalWarning) { + warning = cmStrCat(warning, '\n', additionalWarning); + } + mf.IssueMessage(MessageType::AUTHOR_WARNING, warning); + } CM_FALLTHROUGH; case cmPolicies::OLD: break; diff --git a/Source/cmState.h b/Source/cmState.h index b79f3e603b..702b06ff70 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -183,7 +183,8 @@ public: void AddFlowControlCommand(std::string const& name, Command command); void AddFlowControlCommand(std::string const& name, BuiltinCommand command); void AddDisallowedCommand(std::string const& name, BuiltinCommand command, - cmPolicies::PolicyID policy, const char* message); + cmPolicies::PolicyID policy, const char* message, + const char* additionalWarning = nullptr); void AddUnexpectedCommand(std::string const& name, const char* error); void AddUnexpectedFlowControlCommand(std::string const& name, const char* error);