diff options
author | Brad King <brad.king@kitware.com> | 2023-10-30 12:22:00 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-10-30 12:22:09 (GMT) |
commit | 9e1667e62aa2a83eb8acb4f1cbb2ecb5584f62b1 (patch) | |
tree | c760ffd26b592e948044be73cb172e2cd8f5d7e1 | |
parent | 14563cb7dcc95b0fc2c9089b27239502a8755c75 (diff) | |
parent | d3cc815c989a8f1ddaf8639dc80b9f12350a87c7 (diff) | |
download | CMake-9e1667e62aa2a83eb8acb4f1cbb2ecb5584f62b1.zip CMake-9e1667e62aa2a83eb8acb4f1cbb2ecb5584f62b1.tar.gz CMake-9e1667e62aa2a83eb8acb4f1cbb2ecb5584f62b1.tar.bz2 |
Merge topic 'cmp0153-suggestion' into release-3.28
d3cc815c98 CMP0153: Add suggestion to use execute_process()
8313d26198 cmState::AddDisallowedCommand(): Allow additional warning info
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Brad King <brad.king@kitware.com>
Merge-request: !8921
-rw-r--r-- | Source/cmCommands.cxx | 8 | ||||
-rw-r--r-- | Source/cmState.cxx | 18 | ||||
-rw-r--r-- | Source/cmState.h | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt | 2 |
5 files changed, 23 insertions, 11 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 2ee4f47..91f7691 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -219,9 +219,11 @@ void GetScriptingCommands(cmState* state) state->AddDisallowedCommand( "use_mangled_mesa", cmUseMangledMesaCommand, cmPolicies::CMP0030, "The use_mangled_mesa command should not be called; see CMP0030."); - state->AddDisallowedCommand( - "exec_program", cmExecProgramCommand, cmPolicies::CMP0153, - "The exec_program command should not be called; see CMP0153."); + state->AddDisallowedCommand("exec_program", cmExecProgramCommand, + cmPolicies::CMP0153, + "The exec_program command should not be called; " + "see CMP0153. Use execute_process() instead.", + "Use execute_process() instead."); #endif } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d41e8e5..8ae2166 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<cmListFileArgument>& args, - cmExecutionStatus& status) -> bool { + [command, policy, message, + additionalWarning](const std::vector<cmListFileArgument>& 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 b79f3e6..702b06f 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); diff --git a/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt b/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt index e24eee7..2b0a661 100644 --- a/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt +++ b/Tests/RunCMake/CMP0153/CMP0153-NEW-stderr.txt @@ -1,3 +1,4 @@ ^CMake Error at [^ ]*/Tests/RunCMake/CMP0153/CMP0153-NEW\.cmake:[0-9]+ \(exec_program\): - The exec_program command should not be called; see CMP0153\.$ + The exec_program command should not be called; see CMP0153\. Use + execute_process\(\) instead\.$ diff --git a/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt b/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt index 8f22d4e..d0b9422 100644 --- a/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt +++ b/Tests/RunCMake/CMP0153/CMP0153-WARN-stderr.txt @@ -3,4 +3,6 @@ Policy CMP0153 is not set: The exec_program command should not be called\. Run "cmake --help-policy CMP0153" for policy details\. Use the cmake_policy command to set the policy and suppress this warning\. + + Use execute_process\(\) instead\. This warning is for project developers\. Use -Wno-dev to suppress it\.$ |