cmPolicies.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. CMP0017, // Prefer files in CMAKE_ROOT when including from CMAKE_ROOT
  49. // Always the last entry. Useful mostly to avoid adding a comma
  50. // the last policy when adding a new one.
  51. CMPCOUNT
  52. };
  53. ///! convert a string policy ID into a number
  54. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  55. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  56. ///! Get the default status for a policy
  57. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  58. ///! Define a Policy for CMake
  59. void DefinePolicy(cmPolicies::PolicyID id,
  60. const char *stringID,
  61. const char *shortDescription,
  62. const char *longDescription,
  63. unsigned int majorVersionIntroduced,
  64. unsigned int minorVersionIntroduced,
  65. unsigned int patchVersionIntroduced,
  66. unsigned int tweakVersionIntroduced,
  67. cmPolicies::PolicyStatus status);
  68. ///! Set a policy level for this listfile
  69. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  70. ///! return a warning string for a given policy
  71. std::string GetPolicyWarning(cmPolicies::PolicyID id);
  72. ///! return an error string for when a required policy is unspecified
  73. std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
  74. ///! return an error string for when a required policy is unspecified
  75. std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
  76. ///! Get docs for policies
  77. void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  78. /** Represent a set of policy values. */
  79. typedef std::map<PolicyID, PolicyStatus> PolicyMap;
  80. private:
  81. // might have to make these internal for VS6 not sure yet
  82. std::map<PolicyID,cmPolicy *> Policies;
  83. std::map<std::string,PolicyID> PolicyStringMap;
  84. void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  85. unsigned int majorVer, unsigned int minorVer,
  86. unsigned int patchVer, cmMakefile* mf);
  87. bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
  88. cmPolicies::PolicyStatus* defaultStatus);
  89. };
  90. #endif