cmPolicies.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. CMP0025, ///< Compiler id for Apple Clang is now AppleClang
  72. CMP0026, ///< Disallow use of the LOCATION target property.
  73. CMP0027, ///< Conditionally linked imported targets with missing include
  74. /// directories.
  75. CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target.
  76. CMP0029, ///< Disallow command: subdir_depends
  77. CMP0030, ///< Disallow command: use_mangled_mesa
  78. CMP0031, ///< Disallow command: load_command
  79. CMP0032, ///< Disallow command: output_required_files
  80. CMP0033, ///< Disallow command: export_library_dependencies
  81. CMP0034, ///< Disallow command: utility_source
  82. CMP0035, ///< Disallow command: variable_requires
  83. CMP0036, ///< Disallow command: build_name
  84. CMP0037, ///< Target names should not be reserved and
  85. /// should match a validity pattern.
  86. CMP0038, ///< Targets may not link directly to themselves
  87. CMP0039, ///< Utility targets may not have link dependencies
  88. CMP0040, ///< The target in the TARGET signature of
  89. /// add_custom_command() must exist.
  90. CMP0041, ///< Error on relative include with generator expression
  91. CMP0042, ///< Enable MACOSX_RPATH by default
  92. CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties
  93. CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions
  94. CMP0045, ///< Error on non-existent target in get_target_property
  95. CMP0046, ///< Error on non-existent dependency in add_dependencies
  96. CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX.
  97. CMP0048, ///< project() command manages VERSION variables
  98. CMP0049, ///< Do not expand variables in target source entries
  99. CMP0050, ///< Disallow add_custom_command SOURCE signatures
  100. CMP0051, ///< List TARGET_OBJECTS in SOURCES target property
  101. CMP0052, ///< Reject source and build dirs in installed
  102. /// INTERFACE_INCLUDE_DIRECTORIES
  103. CMP0053, ///< Simplify variable reference and escape sequence evaluation
  104. CMP0054, ///< Only interpret if() arguments as variables
  105. /// or keywords when unquoted.
  106. CMP0055, ///< Strict checking for break() command.
  107. CMP0056, ///< Honor link flags in try_compile() source-file signature.
  108. /** \brief Always the last entry.
  109. *
  110. * Useful mostly to avoid adding a comma the last policy when adding a new
  111. * one.
  112. */
  113. CMPCOUNT
  114. };
  115. ///! convert a string policy ID into a number
  116. bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
  117. std::string GetPolicyIDString(cmPolicies::PolicyID pid);
  118. ///! Get the default status for a policy
  119. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
  120. ///! Define a Policy for CMake
  121. void DefinePolicy(cmPolicies::PolicyID id,
  122. const char *stringID,
  123. const char *shortDescription,
  124. unsigned int majorVersionIntroduced,
  125. unsigned int minorVersionIntroduced,
  126. unsigned int patchVersionIntroduced,
  127. cmPolicies::PolicyStatus status);
  128. ///! Set a policy level for this listfile
  129. bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
  130. ///! return a warning string for a given policy
  131. std::string GetPolicyWarning(cmPolicies::PolicyID id);
  132. ///! return an error string for when a required policy is unspecified
  133. std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
  134. ///! return an error string for when a required policy is unspecified
  135. std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
  136. /** Represent a set of policy values. */
  137. typedef std::map<PolicyID, PolicyStatus> PolicyMap;
  138. private:
  139. // might have to make these internal for VS6 not sure yet
  140. std::map<PolicyID,cmPolicy *> Policies;
  141. std::map<std::string,PolicyID> PolicyStringMap;
  142. void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  143. unsigned int majorVer, unsigned int minorVer,
  144. unsigned int patchVer, cmMakefile* mf);
  145. bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
  146. cmPolicies::PolicyStatus* defaultStatus);
  147. };
  148. #endif