1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCMakePolicyCommand.h,v $
6 Date: $Date: 2009-02-06 13:15:05 $
7 Version: $Revision: 1.10 $
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 =========================================================================*/
17 #ifndef cmCMakePolicyCommand_h
18 #define cmCMakePolicyCommand_h
20 #include "cmCommand.h"
22 /** \class cmCMakePolicyCommand
23 * \brief Set how CMake should handle policies
25 * cmCMakePolicyCommand sets how CMake should deal with backwards
26 * compatibility policies.
28 class cmCMakePolicyCommand
: public cmCommand
32 * This is a virtual constructor for the command.
34 virtual cmCommand
* Clone()
36 return new cmCMakePolicyCommand
;
40 * This is called when the command is first encountered in
41 * the CMakeLists.txt file.
43 virtual bool InitialPass(std::vector
<std::string
> const& args
,
44 cmExecutionStatus
&status
);
47 * This determines if the command is invoked when in script mode.
49 virtual bool IsScriptable() { return true; }
52 * The name of the command as specified in CMakeList.txt.
54 virtual const char* GetName() {return "cmake_policy";}
57 * Succinct documentation.
59 virtual const char* GetTerseDocumentation()
61 return "Manage CMake Policy settings.";
67 virtual const char* GetFullDocumentation()
70 "As CMake evolves it is sometimes necessary to change existing "
71 "behavior in order to fix bugs or improve implementations of "
73 "The CMake Policy mechanism is designed to help keep existing projects "
74 "building as new versions of CMake introduce changes in behavior. "
75 "Each new policy (behavioral change) is given an identifier of "
76 "the form \"CMP<NNNN>\" where \"<NNNN>\" is an integer index. "
77 "Documentation associated with each policy describes the OLD and NEW "
78 "behavior and the reason the policy was introduced. "
79 "Projects may set each policy to select the desired behavior. "
80 "When CMake needs to know which behavior to use it checks for "
81 "a setting specified by the project. "
82 "If no setting is available the OLD behavior is assumed and a warning "
83 "is produced requesting that the policy be set.\n"
84 "The cmake_policy command is used to set policies to OLD or NEW "
86 "While setting policies individually is supported, we encourage "
87 "projects to set policies based on CMake versions.\n"
88 " cmake_policy(VERSION major.minor[.patch])\n"
89 "Specify that the current CMake list file is written for the "
90 "given version of CMake. "
91 "All policies introduced in the specified version or earlier "
92 "will be set to use NEW behavior. "
93 "All policies introduced after the specified version will be unset. "
94 "This effectively requests behavior preferred as of a given CMake "
95 "version and tells newer CMake versions to warn about their new "
97 "The policy version specified must be at least 2.4 or the command "
98 "will report an error. "
99 "In order to get compatibility features supporting versions earlier "
100 "than 2.4 see documentation of policy CMP0001."
102 " cmake_policy(SET CMP<NNNN> NEW)\n"
103 " cmake_policy(SET CMP<NNNN> OLD)\n"
104 "Tell CMake to use the OLD or NEW behavior for a given policy. "
105 "Projects depending on the old behavior of a given policy may "
106 "silence a policy warning by setting the policy state to OLD. "
107 "Alternatively one may fix the project to work with the new behavior "
108 "and set the policy state to NEW."
110 " cmake_policy(GET CMP<NNNN> <variable>)\n"
111 "Check whether a given policy is set to OLD or NEW behavior. "
112 "The output variable value will be \"OLD\" or \"NEW\" if the "
113 "policy is set, and empty otherwise."
115 "CMake keeps policy settings on a stack, so changes made by the "
116 "cmake_policy command affect only the top of the stack. "
117 "A new entry on the policy stack is managed automatically for each "
118 "subdirectory to protect its parents and siblings. "
119 "CMake also manages a new entry for scripts loaded by include() and "
120 "find_package() commands except when invoked with the NO_POLICY_SCOPE "
121 "option (see also policy CMP0011). "
122 "The cmake_policy command provides an interface to manage custom "
123 "entries on the policy stack:\n"
124 " cmake_policy(PUSH)\n"
125 " cmake_policy(POP)\n"
126 "Each PUSH must have a matching POP to erase any changes. "
127 "This is useful to make temporary changes to policy settings."
129 "Functions and macros record policy settings when they are created "
130 "and use the pre-record policies when they are invoked. "
131 "If the function or macro implementation sets policies, the changes "
132 "automatically propagate up through callers until they reach the "
133 "closest nested policy stack entry."
137 cmTypeMacro(cmCMakePolicyCommand
, cmCommand
);
139 bool HandleSetMode(std::vector
<std::string
> const& args
);
140 bool HandleGetMode(std::vector
<std::string
> const& args
);
141 bool HandleVersionMode(std::vector
<std::string
> const& args
);