cmPolicies.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmPolicies_h
  14. #define cmPolicies_h
  15. #include "cmCustomCommand.h"
  16. class cmake;
  17. class cmMakefile;
  18. class cmPolicy;
  19. /** \class cmPolicies
  20. * \brief Handles changes in CMake behavior and policies
  21. *
  22. * See the cmake wiki section on policies for an overview of this class's
  23. * purpose
  24. */
  25. class cmPolicies
  26. {
  27. public:
  28. cmPolicies();
  29. ~cmPolicies();
  30. enum PolicyStatus { OLD, WARN, NEW, REQUIRED_IF_USED, REQUIRED_ALWAYS };
  31. static const char* PolicyStatusNames[];
  32. enum PolicyID
  33. {
  34. CMP0000, // Policy version specification
  35. CMP0001, // Ignore old compatibility variable
  36. CMP0002, // Target names must be unique
  37. CMP0003, // Linking does not include extra -L paths
  38. CMP0004, // Libraries linked may not have leading or trailing whitespace
  39. // Always the last entry. Useful mostly to avoid adding a comma
  40. // the last policy when adding a new one.
  41. CMPCOUNT
  42. };
  43. ///! convert a string policy ID into a number
  44. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  45. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  46. ///! Get the default status for a policy
  47. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  48. ///! Define a Policy for CMake
  49. void DefinePolicy(cmPolicies::PolicyID id,
  50. const char *stringID,
  51. const char *shortDescription,
  52. const char *longDescription,
  53. unsigned int majorVersionIntroduced,
  54. unsigned int minorVersionIntroduced,
  55. unsigned int patchVersionIntroduced,
  56. cmPolicies::PolicyStatus status);
  57. ///! Set a policy level for this listfile
  58. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  59. ///! test to see if setting a policy to a specific value is valid
  60. bool IsValidPolicyStatus(cmPolicies::PolicyID id,
  61. cmPolicies::PolicyStatus status);
  62. ///! test to see if setting a policy to a specific value is valid, when used
  63. bool IsValidUsedPolicyStatus(cmPolicies::PolicyID id,
  64. cmPolicies::PolicyStatus status);
  65. ///! return a warning string for a given policy
  66. std::string GetPolicyWarning(cmPolicies::PolicyID id);
  67. ///! return an error string for when a required policy is unspecified
  68. std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
  69. ///! Get docs for policies
  70. void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  71. private:
  72. // might have to make these internal for VS6 not sure yet
  73. std::map<PolicyID,cmPolicy *> Policies;
  74. std::map<std::string,PolicyID> PolicyStringMap;
  75. };
  76. #endif