1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
15 #include "cmCustomCommand.h"
22 * \brief Handles changes in CMake behavior and policies
24 * See the cmake wiki section on
25 * <a href="http://www.cmake.org/Wiki/CMake/Policies">policies</a>
26 * for an overview of this class's purpose
34 /// Status of a policy
36 OLD, ///< Use old behavior
37 WARN, ///< Use old behavior but issue a warning
38 NEW, ///< Use new behavior
39 /// Issue an error if user doesn't set policy status to NEW and hits the
42 REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
44 static const char* PolicyStatusNames[];
46 /// Policy identifiers
49 CMP0000, ///< Policy version specification
50 CMP0001, ///< Ignore old compatibility variable
51 CMP0002, ///< Target names must be unique
52 CMP0003, ///< Linking does not include extra -L paths
53 CMP0004, ///< Libraries linked may not have leading or trailing whitespace
54 CMP0005, ///< Definition value escaping
55 CMP0006, ///< BUNDLE install rules needed for MACOSX_BUNDLE targets
56 CMP0007, ///< list command handling of empty elements
57 CMP0008, ///< Full-path libraries must be a valid library file name
58 CMP0009, ///< GLOB_RECURSE should not follow symlinks by default
59 CMP0010, ///< Bad variable reference syntax is an error
60 CMP0011, ///< Strong policy scope for include and find_package
61 CMP0012, ///< Recognize numbers and boolean constants in if()
62 CMP0013, ///< Duplicate binary directories not allowed
63 CMP0014, ///< Input directories must have CMakeLists.txt
64 CMP0015, ///< link_directories() treats paths relative to source dir
65 /// target_link_libraries() fails if only argument is not a target
67 CMP0017, ///< Prefer files in CMAKE_ROOT when including from CMAKE_ROOT
68 CMP0018, ///< Ignore language flags for shared libs, and adhere to
69 /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C}
72 /** \brief Always the last entry.
74 * Useful mostly to avoid adding a comma the last policy when adding a new
80 ///! convert a string policy ID into a number
81 bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
82 std::string GetPolicyIDString(cmPolicies::PolicyID pid);
84 ///! Get the default status for a policy
85 cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
87 ///! Define a Policy for CMake
88 void DefinePolicy(cmPolicies::PolicyID id,
90 const char *shortDescription,
91 const char *longDescription,
92 unsigned int majorVersionIntroduced,
93 unsigned int minorVersionIntroduced,
94 unsigned int patchVersionIntroduced,
95 unsigned int tweakVersionIntroduced,
96 cmPolicies::PolicyStatus status);
98 ///! Set a policy level for this listfile
99 bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
101 ///! return a warning string for a given policy
102 std::string GetPolicyWarning(cmPolicies::PolicyID id);
104 ///! return an error string for when a required policy is unspecified
105 std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
107 ///! return an error string for when a required policy is unspecified
108 std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
110 ///! Get docs for policies
111 void GetDocumentation(std::vector<cmDocumentationEntry>& v);
113 /** Represent a set of policy values. */
114 typedef std::map<PolicyID, PolicyStatus> PolicyMap;
117 // might have to make these internal for VS6 not sure yet
118 std::map<PolicyID,cmPolicy *> Policies;
119 std::map<std::string,PolicyID> PolicyStringMap;
121 void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
122 unsigned int majorVer, unsigned int minorVer,
123 unsigned int patchVer, cmMakefile* mf);
125 bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
126 cmPolicies::PolicyStatus* defaultStatus);