1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmPolicies.h,v $
6 Date: $Date: 2008-03-13 21:11:57 $
7 Version: $Revision: 1.13 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
20 #include "cmCustomCommand.h"
27 * \brief Handles changes in CMake behavior and policies
29 * See the cmake wiki section on policies for an overview of this class's
38 enum PolicyStatus
{ OLD
, WARN
, NEW
, REQUIRED_IF_USED
, REQUIRED_ALWAYS
};
39 static const char* PolicyStatusNames
[];
43 CMP0000
, // Policy version specification
44 CMP0001
, // Ignore old compatibility variable
45 CMP0002
, // Target names must be unique
46 CMP0003
, // Linking does not include extra -L paths
47 CMP0004
, // Libraries linked may not have leading or trailing whitespace
48 CMP0005
, // Definition value escaping
50 // Always the last entry. Useful mostly to avoid adding a comma
51 // the last policy when adding a new one.
55 ///! convert a string policy ID into a number
56 bool GetPolicyID(const char *id
, /* out */ cmPolicies::PolicyID
&pid
);
57 std::string
GetPolicyIDString(cmPolicies::PolicyID pid
);
59 ///! Get the default status for a policy
60 cmPolicies::PolicyStatus
GetPolicyStatus(cmPolicies::PolicyID id
);
62 ///! Define a Policy for CMake
63 void DefinePolicy(cmPolicies::PolicyID id
,
65 const char *shortDescription
,
66 const char *longDescription
,
67 unsigned int majorVersionIntroduced
,
68 unsigned int minorVersionIntroduced
,
69 unsigned int patchVersionIntroduced
,
70 cmPolicies::PolicyStatus status
);
72 ///! Set a policy level for this listfile
73 bool ApplyPolicyVersion(cmMakefile
*mf
, const char *version
);
75 ///! test to see if setting a policy to a specific value is valid
76 bool IsValidPolicyStatus(cmPolicies::PolicyID id
,
77 cmPolicies::PolicyStatus status
);
79 ///! test to see if setting a policy to a specific value is valid, when used
80 bool IsValidUsedPolicyStatus(cmPolicies::PolicyID id
,
81 cmPolicies::PolicyStatus status
);
83 ///! return a warning string for a given policy
84 std::string
GetPolicyWarning(cmPolicies::PolicyID id
);
86 ///! return an error string for when a required policy is unspecified
87 std::string
GetRequiredPolicyError(cmPolicies::PolicyID id
);
89 ///! Get docs for policies
90 void GetDocumentation(std::vector
<cmDocumentationEntry
>& v
);
93 // might have to make these internal for VS6 not sure yet
94 std::map
<PolicyID
,cmPolicy
*> Policies
;
95 std::map
<std::string
,PolicyID
> PolicyStringMap
;