1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCMakePolicyCommand.cxx,v $
6 Date: $Date: 2008-03-05 23:21:09 $
7 Version: $Revision: 1.2 $
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 #include "cmCMakePolicyCommand.h"
19 #include "cmVersion.h"
21 // cmCMakePolicyCommand
22 bool cmCMakePolicyCommand
23 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
27 this->SetError("requires at least one argument.");
33 return this->HandleSetMode(args
);
35 else if(args
[0] == "PUSH")
39 this->SetError("PUSH may not be given additional arguments.");
42 return this->Makefile
->PushPolicy();
44 else if(args
[0] == "POP")
48 this->SetError("POP may not be given additional arguments.");
51 if(this->Makefile
->PopPolicy(false))
57 this->SetError("POP without matching PUSH");
61 else if(args
[0] == "VERSION")
63 return this->HandleVersionMode(args
);
67 e
<< "given unknown first argument \"" << args
[0] << "\"";
68 this->SetError(e
.str().c_str());
72 //----------------------------------------------------------------------------
73 bool cmCMakePolicyCommand::HandleSetMode(std::vector
<std::string
> const& args
)
77 this->SetError("SET must be given exactly 2 additional arguments.");
81 cmPolicies::PolicyStatus status
;
84 status
= cmPolicies::OLD
;
86 else if(args
[2] == "NEW")
88 status
= cmPolicies::NEW
;
93 e
<< "SET given unrecognized policy status \"" << args
[2] << "\"";
94 this->SetError(e
.str().c_str());
98 if(!this->Makefile
->SetPolicy(args
[1].c_str(), status
))
100 this->SetError("SET failed to set policy.");
106 //----------------------------------------------------------------------------
108 cmCMakePolicyCommand::HandleVersionMode(std::vector
<std::string
> const& args
)
112 this->SetError("VERSION not given an argument");
115 else if(args
.size() >= 3)
117 this->SetError("VERSION given too many arguments");
120 if(!this->Makefile
->SetPolicyVersion(args
[1].c_str()))
123 e
<< "VERSION given invalid value \"" << args
[1] << "\". "
124 << "A numeric major.minor[.patch] must be given.";
125 this->SetError(e
.str().c_str());