diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-02-06 15:25:45 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-02-06 20:04:16 (GMT) |
commit | 480b3637243d89f59906bee794ababc7cecc220e (patch) | |
tree | c14a914f856fb87b3307b0867b80da7cd37f572f /Source/cmCustomCommand.h | |
parent | dad1234ba11893d44ce0e0e9bf821126ae7d9590 (diff) | |
download | CMake-480b3637243d89f59906bee794ababc7cecc220e.zip CMake-480b3637243d89f59906bee794ababc7cecc220e.tar.gz CMake-480b3637243d89f59906bee794ababc7cecc220e.tar.bz2 |
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.
Diffstat (limited to 'Source/cmCustomCommand.h')
-rw-r--r-- | Source/cmCustomCommand.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 5533847..3671ad9 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -17,6 +17,8 @@ class cmImplicitDependsList { }; +class cmStateSnapshot; + /** \class cmCustomCommand * \brief A class to encapsulate a custom command * @@ -108,9 +110,13 @@ public: const std::string& GetJobPool() const; void SetJobPool(const std::string& job_pool); - /** Set/Get the CMP0116 status (used by the Ninja generator) */ - cmPolicies::PolicyStatus GetCMP0116Status() const; - void SetCMP0116Status(cmPolicies::PolicyStatus cmp0116); +#define DECLARE_CC_POLICY_ACCESSOR(P) \ + cmPolicies::PolicyStatus Get##P##Status() const; + CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DECLARE_CC_POLICY_ACCESSOR) +#undef DECLARE_CC_POLICY_ACCESSOR + + /** Record policy values from state snapshot */ + void RecordPolicyValues(const cmStateSnapshot& snapshot); /** Set/Get the associated target */ const std::string& GetTarget() const; @@ -135,5 +141,11 @@ private: bool CommandExpandLists = false; bool StdPipesUTF8 = false; bool HasMainDependency_ = false; - cmPolicies::PolicyStatus CMP0116Status = cmPolicies::WARN; + +// Policies are NEW for synthesized custom commands, and set by cmMakefile for +// user-created custom commands. +#define DECLARE_CC_POLICY_FIELD(P) \ + cmPolicies::PolicyStatus P##Status = cmPolicies::NEW; + CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DECLARE_CC_POLICY_FIELD) +#undef DECLARE_CC_POLICY_FIELD }; |