Removed curl dependency by using cmake internal curl
[platform/upstream/cmake.git] / Source / cmPolicies.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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 ============================================================================*/
12 #ifndef cmPolicies_h
13 #define cmPolicies_h
14
15 #include "cmCustomCommand.h"
16
17 class cmake;
18 class cmMakefile;
19 class cmPolicy;
20
21 /** \class cmPolicies
22  * \brief Handles changes in CMake behavior and policies
23  *
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
27  */
28 class cmPolicies
29 {
30 public:
31   cmPolicies();
32   ~cmPolicies();
33
34   /// Status of a policy
35   enum PolicyStatus {
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
40     /// check
41     REQUIRED_IF_USED,
42     REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
43   };
44   static const char* PolicyStatusNames[];
45
46   /// Policy identifiers
47   enum PolicyID
48   {
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
66     CMP0016,
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}
70     /// instead.
71     CMP0019, ///< No variable re-expansion in include and link info
72     CMP0020, ///< Automatically link Qt executables to qtmain target
73     CMP0021, ///< Fatal error on relative paths in INCLUDE_DIRECTORIES
74     /// target property
75     CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
76     CMP0023, ///< Disallow mixing keyword and plain tll signatures
77
78     /** \brief Always the last entry.
79      *
80      * Useful mostly to avoid adding a comma the last policy when adding a new
81      * one.
82      */
83     CMPCOUNT
84   };
85
86   ///! convert a string policy ID into a number
87   bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
88   std::string GetPolicyIDString(cmPolicies::PolicyID pid);
89
90   ///! Get the default status for a policy
91   cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
92
93   ///! Define a Policy for CMake
94   void DefinePolicy(cmPolicies::PolicyID id,
95                     const char *stringID,
96                     const char *shortDescription,
97                     const char *longDescription,
98                     unsigned int majorVersionIntroduced,
99                     unsigned int minorVersionIntroduced,
100                     unsigned int patchVersionIntroduced,
101                     unsigned int tweakVersionIntroduced,
102                     cmPolicies::PolicyStatus status);
103
104   ///! Set a policy level for this listfile
105   bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
106
107   ///! return a warning string for a given policy
108   std::string GetPolicyWarning(cmPolicies::PolicyID id);
109
110   ///! return an error string for when a required policy is unspecified
111   std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
112
113   ///! return an error string for when a required policy is unspecified
114   std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
115
116   ///! Get docs for policies
117   void GetDocumentation(std::vector<cmDocumentationEntry>& v);
118
119   /** Represent a set of policy values.  */
120   typedef std::map<PolicyID, PolicyStatus> PolicyMap;
121
122   private:
123   // might have to make these internal for VS6 not sure yet
124   std::map<PolicyID,cmPolicy *> Policies;
125   std::map<std::string,PolicyID> PolicyStringMap;
126
127   void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
128                                unsigned int majorVer, unsigned int minorVer,
129                                unsigned int patchVer, cmMakefile* mf);
130
131   bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
132                         cmPolicies::PolicyStatus* defaultStatus);
133
134 };
135
136 #endif