cmCustomCommand: Refactor custom command-specific policy values

Many custom commands are created by CMake itself rather than by
the user. These custom commands should always have their policies
set to NEW, and user-created custom commands should have their
policy values set only from the state snapshot. In addition, we
want to genericize the mechanism of recording a policy at the time
of custom command creation.

Add a CM_FOR_EACH_CUSTOM_COMMAND_POLICY macro to genericize
custom command policies. Use this to define all custom command
policies. Make all such policies NEW instead of WARN by default.
Remove individual policy modifier methods and add a single method
that records relevant values from a cmStateSnapshot. Remove the
no longer needed explicit policy settings from synthesized custom
commands.
This commit is contained in:
Kyle Edwards
2023-02-06 10:25:45 -05:00
parent dad1234ba1
commit 480b363724
12 changed files with 34 additions and 33 deletions
+13 -6
View File
@@ -7,6 +7,8 @@
#include <cmext/algorithm>
#include "cmStateSnapshot.h"
const std::vector<std::string>& cmCustomCommand::GetOutputs() const
{
return this->Outputs;
@@ -182,14 +184,19 @@ void cmCustomCommand::SetJobPool(const std::string& job_pool)
this->JobPool = job_pool;
}
cmPolicies::PolicyStatus cmCustomCommand::GetCMP0116Status() const
{
return this->CMP0116Status;
}
#define DEFINE_CC_POLICY_ACCESSOR(P) \
cmPolicies::PolicyStatus cmCustomCommand::Get##P##Status() const \
{ \
return this->P##Status; \
}
CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DEFINE_CC_POLICY_ACCESSOR)
#undef DEFINE_CC_POLICY_ACCESSOR
void cmCustomCommand::SetCMP0116Status(cmPolicies::PolicyStatus cmp0116)
void cmCustomCommand::RecordPolicyValues(const cmStateSnapshot& snapshot)
{
this->CMP0116Status = cmp0116;
#define SET_CC_POLICY(P) this->P##Status = snapshot.GetPolicy(cmPolicies::P);
CM_FOR_EACH_CUSTOM_COMMAND_POLICY(SET_CC_POLICY)
#undef SET_CC_POLICY
}
const std::string& cmCustomCommand::GetTarget() const