summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2008-03-01 20:20:35 (GMT)
committerKen Martin <ken.martin@kitware.com>2008-03-01 20:20:35 (GMT)
commitd49ef18f8a9ebe4e512d67d3fb88958c655beb69 (patch)
treea40a7a4649f9a7137579c6c22be29846f97d72c3 /Source/cmMakefile.cxx
parent32ca01bef0fe4218319d9c9fd02ea11336f5e134 (diff)
downloadCMake-d49ef18f8a9ebe4e512d67d3fb88958c655beb69.zip
CMake-d49ef18f8a9ebe4e512d67d3fb88958c655beb69.tar.gz
CMake-d49ef18f8a9ebe4e512d67d3fb88958c655beb69.tar.bz2
ENH: add first cut and policies still need to add the doc support
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx148
1 files changed, 129 insertions, 19 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c87a4dd..18348c1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -291,24 +291,14 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
this->GetCMakeInstance()->GetCommand(name.c_str());
if(rm)
{
- const char* versionValue
- = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
- int major = 0;
- int minor = 0;
- if ( versionValue )
- {
- sscanf(versionValue, "%d.%d", &major, &minor);
- }
- if ( rm->IsDeprecated(major, minor) )
- {
- cmOStringStream error;
- error << "Error in cmake code at\n"
- << lff.FilePath << ":" << lff.Line << ":\n"
- << rm->GetError() << std::endl
- << " Called from: " << this->GetListFileStack().c_str();
- cmSystemTools::Error(error.str().c_str());
- return false;
- }
+ // const char* versionValue
+ // = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
+ // int major = 0;
+ // int minor = 0;
+ // if ( versionValue )
+ // {
+ // sscanf(versionValue, "%d.%d", &major, &minor);
+ // }
cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this);
bool keepCommand = false;
@@ -3148,8 +3138,24 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
msg = e.str();
return false;
}
- else if(!this->NeedBackwardsCompatibility(2, 4))
+ else
{
+ // target names must be globally unique
+ switch (this->GetPolicyStatus(cmPolicies::CMP_0002))
+ {
+ case cmPolicies::WARN:
+ msg = this->GetPolicies()->
+ GetPolicyWarning(cmPolicies::CMP_0002);
+ case cmPolicies::OLD:
+ return true;
+ case cmPolicies::REQUIRED_IF_USED:
+ msg = this->GetPolicies()->
+ GetRequiredPolicyError(cmPolicies::CMP_0002);
+ return false;
+ case cmPolicies::NEW:
+ break;
+ }
+
// The conflict is with a non-imported target.
// Allow this if the user has requested support.
cmake* cm =
@@ -3225,3 +3231,107 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
}
return true;
}
+
+cmPolicies::PolicyStatus cmMakefile
+::GetPolicyStatus(cmPolicies::PolicyID id)
+{
+ cmPolicies::PolicyStatus status;
+ PolicyMap::iterator mappos;
+ unsigned int vecpos;
+ bool done = false;
+ // check our policy stack first
+ for (vecpos = this->PolicyStack.size(); vecpos >= 0 && !done; vecpos--)
+ {
+ mappos = this->PolicyStack[vecpos].find(id);
+ if (mappos != this->PolicyStack[vecpos].end())
+ {
+ status = mappos->second;
+ done = true;
+ }
+ }
+
+ // if not found then
+ if (!done)
+ {
+ // pass the buck to our parent if we have one
+ if (this->LocalGenerator->GetParent())
+ {
+ cmMakefile *parent =
+ this->LocalGenerator->GetParent()->GetMakefile();
+ return parent->GetPolicyStatus(id);
+ }
+ // otherwise use the default
+ else
+ {
+ status = this->GetPolicies()->GetPolicyStatus(id);
+ }
+ }
+
+ // warn if we see a REQUIRED_IF_USED above a OLD or WARN
+ if (!this->GetPolicies()->IsValidUsedPolicyStatus(id,status))
+ {
+ return cmPolicies::REQUIRED_IF_USED;
+ }
+
+ return status;
+}
+
+bool cmMakefile::SetPolicy(const char *id,
+ cmPolicies::PolicyStatus status)
+{
+ cmPolicies::PolicyID pid;
+ if (!this->GetPolicies()->GetPolicyID(id, /* out */ pid))
+ {
+ cmSystemTools::Error("Invalid policy string used. Invalid string was "
+ , id);
+ return false;
+ }
+ return this->SetPolicy(pid,status);
+}
+
+bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
+ cmPolicies::PolicyStatus status)
+{
+ // setting a REQUIRED_ALWAYS policy to WARN or OLD is an insta error
+ if (this->GetPolicies()->
+ IsValidPolicyStatus(id,status))
+ {
+ this->PolicyStack.back()[id] = status;
+ return true;
+ }
+ return false;
+}
+
+bool cmMakefile::PushPolicy()
+{
+ // Allocate a new stack entry.
+ this->PolicyStack.push_back(PolicyMap());
+ return true;
+}
+
+bool cmMakefile::PopPolicy()
+{
+ if (PolicyStack.size() == 0)
+ {
+ cmSystemTools::Error("Attempt to pop the policy stack past "
+ "it's beginning.");
+ return false;
+ }
+ this->PolicyStack.pop_back();
+ return true;
+}
+
+bool cmMakefile::SetPolicyVersion(const char *version)
+{
+ return this->GetCMakeInstance()->GetPolicies()->
+ ApplyPolicyVersion(this,version);
+}
+
+cmPolicies *cmMakefile::GetPolicies()
+{
+ if (!this->GetCMakeInstance())
+ {
+ return 0;
+ }
+ return this->GetCMakeInstance()->GetPolicies();
+}