cmPolicies.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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, // Recognize numbers and boolean constants in if()
  44. CMP0013, // Duplicate binary directories not allowed
  45. CMP0014, // Input directories must have CMakeLists.txt
  46. CMP0015, // link_directories() treats paths relative to source dir
  47. CMP0016, // target_link_libraries() fails if only argument is not a target
  48. // Always the last entry. Useful mostly to avoid adding a comma
  49. // the last policy when adding a new one.
  50. CMPCOUNT
  51. };
  52. ///! convert a string policy ID into a number
  53. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  54. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  55. ///! Get the default status for a policy
  56. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  57. ///! Define a Policy for CMake
  58. void DefinePolicy(cmPolicies::PolicyID id,
  59. const char *stringID,
  60. const char *shortDescription,
  61. const char *longDescription,
  62. unsigned int majorVersionIntroduced,
  63. unsigned int minorVersionIntroduced,
  64. unsigned int patchVersionIntroduced,
  65. unsigned int tweakVersionIntroduced,
  66. cmPolicies::PolicyStatus status);
  67. ///! Set a policy level for this listfile
  68. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  69. ///! return a warning string for a given policy
  70. std::string GetPolicyWarning(cmPolicies::PolicyID id);
  71. ///! return an error string for when a required policy is unspecified
  72. std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
  73. ///! return an error string for when a required policy is unspecified
  74. std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
  75. ///! Get docs for policies
  76. void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  77. /** Represent a set of policy values. */
  78. typedef std::map<PolicyID, PolicyStatus> PolicyMap;
  79. private:
  80. // might have to make these internal for VS6 not sure yet
  81. std::map<PolicyID,cmPolicy *> Policies;
  82. std::map<std::string,PolicyID> PolicyStringMap;
  83. void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  84. unsigned int majorVer, unsigned int minorVer,
  85. unsigned int patchVer, cmMakefile* mf);
  86. bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
  87. cmPolicies::PolicyStatus* defaultStatus);
  88. };
  89. #endif