1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmPolicies.h,v $
6 Date: $Date: 2009-09-10 20:59:44 $
7 Version: $Revision: 1.26 $
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
49 CMP0006
, // BUNDLE install rules needed for MACOSX_BUNDLE targets
50 CMP0007
, // list command handling of empty elements
51 CMP0008
, // Full-path libraries must be a valid library file name
52 CMP0009
, // GLOB_RECURSE should not follow symlinks by default
53 CMP0010
, // Bad variable reference syntax is an error
54 CMP0011
, // Strong policy scope for include and find_package
55 CMP0012
, // Strong handling of boolean constants
56 CMP0013
, // Duplicate binary directories not allowed
57 CMP0014
, // Input directories must have CMakeLists.txt
58 CMP0015
, // set(CACHE) and option() make CACHE value visible
60 // Always the last entry. Useful mostly to avoid adding a comma
61 // the last policy when adding a new one.
65 ///! convert a string policy ID into a number
66 bool GetPolicyID(const char *id
, /* out */ cmPolicies::PolicyID
&pid
);
67 std::string
GetPolicyIDString(cmPolicies::PolicyID pid
);
69 ///! Get the default status for a policy
70 cmPolicies::PolicyStatus
GetPolicyStatus(cmPolicies::PolicyID id
);
72 ///! Define a Policy for CMake
73 void DefinePolicy(cmPolicies::PolicyID id
,
75 const char *shortDescription
,
76 const char *longDescription
,
77 unsigned int majorVersionIntroduced
,
78 unsigned int minorVersionIntroduced
,
79 unsigned int patchVersionIntroduced
,
80 cmPolicies::PolicyStatus status
);
82 ///! Set a policy level for this listfile
83 bool ApplyPolicyVersion(cmMakefile
*mf
, const char *version
);
85 ///! return a warning string for a given policy
86 std::string
GetPolicyWarning(cmPolicies::PolicyID id
);
88 ///! return an error string for when a required policy is unspecified
89 std::string
GetRequiredPolicyError(cmPolicies::PolicyID id
);
91 ///! return an error string for when a required policy is unspecified
92 std::string
GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id
);
94 ///! Get docs for policies
95 void GetDocumentation(std::vector
<cmDocumentationEntry
>& v
);
97 /** Represent a set of policy values. */
98 typedef std::map
<PolicyID
, PolicyStatus
> PolicyMap
;
101 // might have to make these internal for VS6 not sure yet
102 std::map
<PolicyID
,cmPolicy
*> Policies
;
103 std::map
<std::string
,PolicyID
> PolicyStringMap
;
105 void DiagnoseAncientPolicies(std::vector
<PolicyID
> const& ancient
,
106 unsigned int majorVer
, unsigned int minorVer
,
107 unsigned int patchVer
, cmMakefile
* mf
);