cmPolicies.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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
  20. * <a href="http://www.cmake.org/Wiki/CMake/Policies">policies</a>
  21. * for an overview of this class's purpose
  22. */
  23. class cmPolicies
  24. {
  25. public:
  26. cmPolicies();
  27. ~cmPolicies();
  28. /// Status of a policy
  29. enum PolicyStatus {
  30. OLD, ///< Use old behavior
  31. WARN, ///< Use old behavior but issue a warning
  32. NEW, ///< Use new behavior
  33. /// Issue an error if user doesn't set policy status to NEW and hits the
  34. /// check
  35. REQUIRED_IF_USED,
  36. REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
  37. };
  38. static const char* PolicyStatusNames[];
  39. /// Policy identifiers
  40. enum PolicyID
  41. {
  42. CMP0000, ///< Policy version specification
  43. CMP0001, ///< Ignore old compatibility variable
  44. CMP0002, ///< Target names must be unique
  45. CMP0003, ///< Linking does not include extra -L paths
  46. CMP0004, ///< Libraries linked may not have leading or trailing whitespace
  47. CMP0005, ///< Definition value escaping
  48. CMP0006, ///< BUNDLE install rules needed for MACOSX_BUNDLE targets
  49. CMP0007, ///< list command handling of empty elements
  50. CMP0008, ///< Full-path libraries must be a valid library file name
  51. CMP0009, ///< GLOB_RECURSE should not follow symlinks by default
  52. CMP0010, ///< Bad variable reference syntax is an error
  53. CMP0011, ///< Strong policy scope for include and find_package
  54. CMP0012, ///< Recognize numbers and boolean constants in if()
  55. CMP0013, ///< Duplicate binary directories not allowed
  56. CMP0014, ///< Input directories must have CMakeLists.txt
  57. CMP0015, ///< link_directories() treats paths relative to source dir
  58. /// target_link_libraries() fails if only argument is not a target
  59. CMP0016,
  60. CMP0017, ///< Prefer files in CMAKE_ROOT when including from CMAKE_ROOT
  61. CMP0018, ///< Ignore language flags for shared libs, and adhere to
  62. /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C}
  63. /// instead.
  64. CMP0019, ///< No variable re-expansion in include and link info
  65. CMP0020, ///< Automatically link Qt executables to qtmain target
  66. CMP0021, ///< Fatal error on relative paths in INCLUDE_DIRECTORIES
  67. /// target property
  68. CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
  69. CMP0023, ///< Disallow mixing keyword and plain tll signatures
  70. CMP0024, ///< Disallow including export() result.
  71. /** \brief Always the last entry.
  72. *
  73. * Useful mostly to avoid adding a comma the last policy when adding a new
  74. * one.
  75. */
  76. CMPCOUNT
  77. };
  78. ///! convert a string policy ID into a number
  79. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  80. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  81. ///! Get the default status for a policy
  82. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  83. ///! Define a Policy for CMake
  84. void DefinePolicy(cmPolicies::PolicyID id,
  85. const char *stringID,
  86. const char *shortDescription,
  87. const char *longDescription,
  88. unsigned int majorVersionIntroduced,
  89. unsigned int minorVersionIntroduced,
  90. unsigned int patchVersionIntroduced,
  91. unsigned int tweakVersionIntroduced,
  92. cmPolicies::PolicyStatus status);
  93. ///! Set a policy level for this listfile
  94. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  95. ///! return a warning string for a given policy
  96. std::string GetPolicyWarning(cmPolicies::PolicyID id);
  97. ///! return an error string for when a required policy is unspecified
  98. std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
  99. ///! return an error string for when a required policy is unspecified
  100. std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
  101. ///! Get docs for policies
  102. void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  103. /** Represent a set of policy values. */
  104. typedef std::map<PolicyID, PolicyStatus> PolicyMap;
  105. private:
  106. // might have to make these internal for VS6 not sure yet
  107. std::map<PolicyID,cmPolicy *> Policies;
  108. std::map<std::string,PolicyID> PolicyStringMap;
  109. void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  110. unsigned int majorVer, unsigned int minorVer,
  111. unsigned int patchVer, cmMakefile* mf);
  112. bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
  113. cmPolicies::PolicyStatus* defaultStatus);
  114. };
  115. #endif