cmPolicies.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. CMP0005, // Definition value escaping
  40. CMP0006, // BUNDLE install rules needed for MACOSX_BUNDLE targets
  41. CMP0007, // list command handling of empty elements
  42. CMP0008, // Full-path libraries must be a valid library file name
  43. CMP0009, // GLOB_RECURSE should not follow symlinks by default
  44. CMP0010, // Bad variable reference syntax is an error
  45. // Always the last entry. Useful mostly to avoid adding a comma
  46. // the last policy when adding a new one.
  47. CMPCOUNT
  48. };
  49. ///! convert a string policy ID into a number
  50. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  51. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  52. ///! Get the default status for a policy
  53. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  54. ///! Define a Policy for CMake
  55. void DefinePolicy(cmPolicies::PolicyID id,
  56. const char *stringID,
  57. const char *shortDescription,
  58. const char *longDescription,
  59. unsigned int majorVersionIntroduced,
  60. unsigned int minorVersionIntroduced,
  61. unsigned int patchVersionIntroduced,
  62. cmPolicies::PolicyStatus status);
  63. ///! Set a policy level for this listfile
  64. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  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. ///! return an error string for when a required policy is unspecified
  70. std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
  71. ///! Get docs for policies
  72. void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  73. private:
  74. // might have to make these internal for VS6 not sure yet
  75. std::map<PolicyID,cmPolicy *> Policies;
  76. std::map<std::string,PolicyID> PolicyStringMap;
  77. void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  78. unsigned int majorVer, unsigned int minorVer,
  79. unsigned int patchVer, cmMakefile* mf);
  80. };
  81. #endif