2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-02-29 23:28:46 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-02-29 23:28:46 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2008-02-29 23:28:46 +03:00
|
|
|
#ifndef cmCMakePolicyCommand_h
|
|
|
|
#define cmCMakePolicyCommand_h
|
|
|
|
|
|
|
|
#include "cmCommand.h"
|
|
|
|
|
|
|
|
/** \class cmCMakePolicyCommand
|
|
|
|
* \brief Set how CMake should handle policies
|
|
|
|
*
|
2012-08-13 21:42:58 +04:00
|
|
|
* cmCMakePolicyCommand sets how CMake should deal with backwards
|
|
|
|
* compatibility policies.
|
2008-02-29 23:28:46 +03:00
|
|
|
*/
|
|
|
|
class cmCMakePolicyCommand : public cmCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* This is a virtual constructor for the command.
|
|
|
|
*/
|
2012-08-13 21:42:58 +04:00
|
|
|
virtual cmCommand* Clone()
|
2008-02-29 23:28:46 +03:00
|
|
|
{
|
|
|
|
return new cmCMakePolicyCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called when the command is first encountered in
|
|
|
|
* the CMakeLists.txt file.
|
|
|
|
*/
|
|
|
|
virtual bool InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus &status);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This determines if the command is invoked when in script mode.
|
|
|
|
*/
|
2012-02-25 10:49:24 +04:00
|
|
|
virtual bool IsScriptable() const { return true; }
|
2008-02-29 23:28:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the command as specified in CMakeList.txt.
|
|
|
|
*/
|
2012-02-25 10:49:24 +04:00
|
|
|
virtual const char* GetName() const {return "cmake_policy";}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-02-29 23:28:46 +03:00
|
|
|
/**
|
|
|
|
* Succinct documentation.
|
|
|
|
*/
|
2012-02-25 10:49:24 +04:00
|
|
|
virtual const char* GetTerseDocumentation() const
|
2008-02-29 23:28:46 +03:00
|
|
|
{
|
2008-03-18 03:30:47 +03:00
|
|
|
return "Manage CMake Policy settings.";
|
2008-02-29 23:28:46 +03:00
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-02-29 23:28:46 +03:00
|
|
|
/**
|
|
|
|
* More documentation.
|
|
|
|
*/
|
2012-02-25 10:49:24 +04:00
|
|
|
virtual const char* GetFullDocumentation() const
|
2008-02-29 23:28:46 +03:00
|
|
|
{
|
|
|
|
return
|
2008-03-18 03:30:47 +03:00
|
|
|
"As CMake evolves it is sometimes necessary to change existing "
|
|
|
|
"behavior in order to fix bugs or improve implementations of "
|
|
|
|
"existing features. "
|
|
|
|
"The CMake Policy mechanism is designed to help keep existing projects "
|
|
|
|
"building as new versions of CMake introduce changes in behavior. "
|
|
|
|
"Each new policy (behavioral change) is given an identifier of "
|
|
|
|
"the form \"CMP<NNNN>\" where \"<NNNN>\" is an integer index. "
|
|
|
|
"Documentation associated with each policy describes the OLD and NEW "
|
|
|
|
"behavior and the reason the policy was introduced. "
|
|
|
|
"Projects may set each policy to select the desired behavior. "
|
|
|
|
"When CMake needs to know which behavior to use it checks for "
|
|
|
|
"a setting specified by the project. "
|
|
|
|
"If no setting is available the OLD behavior is assumed and a warning "
|
|
|
|
"is produced requesting that the policy be set.\n"
|
|
|
|
"The cmake_policy command is used to set policies to OLD or NEW "
|
|
|
|
"behavior. "
|
|
|
|
"While setting policies individually is supported, we encourage "
|
|
|
|
"projects to set policies based on CMake versions.\n"
|
2010-04-23 17:50:31 +04:00
|
|
|
" cmake_policy(VERSION major.minor[.patch[.tweak]])\n"
|
2008-03-06 02:21:10 +03:00
|
|
|
"Specify that the current CMake list file is written for the "
|
|
|
|
"given version of CMake. "
|
|
|
|
"All policies introduced in the specified version or earlier "
|
2008-03-18 03:30:47 +03:00
|
|
|
"will be set to use NEW behavior. "
|
2011-01-04 02:04:58 +03:00
|
|
|
"All policies introduced after the specified version will be unset "
|
|
|
|
"(unless variable CMAKE_POLICY_DEFAULT_CMP<NNNN> sets a default). "
|
2008-03-06 02:21:10 +03:00
|
|
|
"This effectively requests behavior preferred as of a given CMake "
|
|
|
|
"version and tells newer CMake versions to warn about their new "
|
2008-03-07 23:30:35 +03:00
|
|
|
"policies. "
|
|
|
|
"The policy version specified must be at least 2.4 or the command "
|
|
|
|
"will report an error. "
|
|
|
|
"In order to get compatibility features supporting versions earlier "
|
2008-03-13 18:38:46 +03:00
|
|
|
"than 2.4 see documentation of policy CMP0001."
|
2008-03-06 02:21:10 +03:00
|
|
|
"\n"
|
2008-03-18 03:30:47 +03:00
|
|
|
" cmake_policy(SET CMP<NNNN> NEW)\n"
|
|
|
|
" cmake_policy(SET CMP<NNNN> OLD)\n"
|
2008-03-06 02:21:10 +03:00
|
|
|
"Tell CMake to use the OLD or NEW behavior for a given policy. "
|
|
|
|
"Projects depending on the old behavior of a given policy may "
|
|
|
|
"silence a policy warning by setting the policy state to OLD. "
|
|
|
|
"Alternatively one may fix the project to work with the new behavior "
|
|
|
|
"and set the policy state to NEW."
|
|
|
|
"\n"
|
2008-08-18 17:53:06 +04:00
|
|
|
" cmake_policy(GET CMP<NNNN> <variable>)\n"
|
|
|
|
"Check whether a given policy is set to OLD or NEW behavior. "
|
|
|
|
"The output variable value will be \"OLD\" or \"NEW\" if the "
|
|
|
|
"policy is set, and empty otherwise."
|
|
|
|
"\n"
|
2009-01-22 21:16:33 +03:00
|
|
|
"CMake keeps policy settings on a stack, so changes made by the "
|
|
|
|
"cmake_policy command affect only the top of the stack. "
|
|
|
|
"A new entry on the policy stack is managed automatically for each "
|
|
|
|
"subdirectory to protect its parents and siblings. "
|
2009-01-22 21:18:40 +03:00
|
|
|
"CMake also manages a new entry for scripts loaded by include() and "
|
|
|
|
"find_package() commands except when invoked with the NO_POLICY_SCOPE "
|
|
|
|
"option (see also policy CMP0011). "
|
2009-01-22 21:16:33 +03:00
|
|
|
"The cmake_policy command provides an interface to manage custom "
|
|
|
|
"entries on the policy stack:\n"
|
2008-02-29 23:28:46 +03:00
|
|
|
" cmake_policy(PUSH)\n"
|
|
|
|
" cmake_policy(POP)\n"
|
2009-01-22 21:16:33 +03:00
|
|
|
"Each PUSH must have a matching POP to erase any changes. "
|
|
|
|
"This is useful to make temporary changes to policy settings."
|
2009-01-22 21:16:47 +03:00
|
|
|
"\n"
|
|
|
|
"Functions and macros record policy settings when they are created "
|
|
|
|
"and use the pre-record policies when they are invoked. "
|
|
|
|
"If the function or macro implementation sets policies, the changes "
|
|
|
|
"automatically propagate up through callers until they reach the "
|
|
|
|
"closest nested policy stack entry."
|
2009-01-22 21:16:33 +03:00
|
|
|
;
|
2008-02-29 23:28:46 +03:00
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-02-29 23:28:46 +03:00
|
|
|
cmTypeMacro(cmCMakePolicyCommand, cmCommand);
|
2008-03-06 02:21:10 +03:00
|
|
|
private:
|
|
|
|
bool HandleSetMode(std::vector<std::string> const& args);
|
2008-08-18 17:53:06 +04:00
|
|
|
bool HandleGetMode(std::vector<std::string> const& args);
|
2008-03-06 02:21:10 +03:00
|
|
|
bool HandleVersionMode(std::vector<std::string> const& args);
|
2008-02-29 23:28:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|