1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCMakePolicyCommand.h,v $
6 Date: $Date: 2008-08-18 13:53:06 $
7 Version: $Revision: 1.6 $
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 reset "
94 "to use OLD behavior with a warning. "
95 "This effectively requests behavior preferred as of a given CMake "
96 "version and tells newer CMake versions to warn about their new "
98 "The policy version specified must be at least 2.4 or the command "
99 "will report an error. "
100 "In order to get compatibility features supporting versions earlier "
101 "than 2.4 see documentation of policy CMP0001."
103 " cmake_policy(SET CMP<NNNN> NEW)\n"
104 " cmake_policy(SET CMP<NNNN> OLD)\n"
105 "Tell CMake to use the OLD or NEW behavior for a given policy. "
106 "Projects depending on the old behavior of a given policy may "
107 "silence a policy warning by setting the policy state to OLD. "
108 "Alternatively one may fix the project to work with the new behavior "
109 "and set the policy state to NEW."
111 " cmake_policy(GET CMP<NNNN> <variable>)\n"
112 "Check whether a given policy is set to OLD or NEW behavior. "
113 "The output variable value will be \"OLD\" or \"NEW\" if the "
114 "policy is set, and empty otherwise."
116 " cmake_policy(PUSH)\n"
117 " cmake_policy(POP)\n"
118 "Push and pop the current policy setting state on a stack. "
119 "Each PUSH must have a matching POP. "
120 "This is useful when mixing multiple projects, subprojects, and "
121 "files included from external projects that may each have been "
122 "written for a different version of CMake. "
123 "Each subdirectory entered by the project automatically pushes "
124 "a new level on the stack to isolate the subdirectories from "
128 cmTypeMacro(cmCMakePolicyCommand
, cmCommand
);
130 bool HandleSetMode(std::vector
<std::string
> const& args
);
131 bool HandleGetMode(std::vector
<std::string
> const& args
);
132 bool HandleVersionMode(std::vector
<std::string
> const& args
);