cmPolicies.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmPolicies_h
  11. #define cmPolicies_h
  12. #include "cmCustomCommand.h"
  13. class cmake;
  14. class cmMakefile;
  15. class cmPolicy;
  16. /** \class cmPolicies
  17. * \brief Handles changes in CMake behavior and policies
  18. *
  19. * See the cmake wiki section on policies for an overview of this class's
  20. * purpose
  21. */
  22. class cmPolicies
  23. {
  24. public:
  25. cmPolicies();
  26. ~cmPolicies();
  27. enum PolicyStatus { OLD, WARN, NEW, REQUIRED_IF_USED, REQUIRED_ALWAYS };
  28. static const char* PolicyStatusNames[];
  29. enum PolicyID
  30. {
  31. CMP0000, // Policy version specification
  32. CMP0001, // Ignore old compatibility variable
  33. CMP0002, // Target names must be unique
  34. CMP0003, // Linking does not include extra -L paths
  35. CMP0004, // Libraries linked may not have leading or trailing whitespace
  36. CMP0005, // Definition value escaping
  37. CMP0006, // BUNDLE install rules needed for MACOSX_BUNDLE targets
  38. CMP0007, // list command handling of empty elements
  39. CMP0008, // Full-path libraries must be a valid library file name
  40. CMP0009, // GLOB_RECURSE should not follow symlinks by default
  41. CMP0010, // Bad variable reference syntax is an error
  42. CMP0011, // Strong policy scope for include and find_package
  43. CMP0012, // Strong handling of boolean constants
  44. CMP0013, // Duplicate binary directories not allowed
  45. CMP0014, // Input directories must have CMakeLists.txt
  46. CMP0015, // set(CACHE) and option() make CACHE value visible
  47. // Always the last entry. Useful mostly to avoid adding a comma
  48. // the last policy when adding a new one.
  49. CMPCOUNT
  50. };
  51. ///! convert a string policy ID into a number
  52. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  53. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  54. ///! Get the default status for a policy
  55. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  56. ///! Define a Policy for CMake
  57. void DefinePolicy(cmPolicies::PolicyID id,
  58. const char *stringID,
  59. const char *shortDescription,
  60. const char *longDescription,
  61. unsigned int majorVersionIntroduced,
  62. unsigned int minorVersionIntroduced,
  63. unsigned int patchVersionIntroduced,
  64. cmPolicies::PolicyStatus status);
  65. ///! Set a policy level for this listfile
  66. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  67. ///! return a warning string for a given policy
  68. std::string GetPolicyWarning(cmPolicies::PolicyID id);
  69. ///! return an error string for when a required policy is unspecified
  70. std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
  71. ///! return an error string for when a required policy is unspecified
  72. std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
  73. ///! Get docs for policies
  74. void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  75. /** Represent a set of policy values. */
  76. typedef std::map<PolicyID, PolicyStatus> PolicyMap;
  77. private:
  78. // might have to make these internal for VS6 not sure yet
  79. std::map<PolicyID,cmPolicy *> Policies;
  80. std::map<std::string,PolicyID> PolicyStringMap;
  81. void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  82. unsigned int majorVer, unsigned int minorVer,
  83. unsigned int patchVer, cmMakefile* mf);
  84. };
  85. #endif