Merge topic 'move-CMP0059-handling'
52b9d828
cmMakefile: Move CMP0059 handling to command code.fe603c7d
cmGetDirectoryPropertyCommand: Move variable to the point of use.8fc53c3c
cmGetDirectoryPropertyCommand: Extract StoreResult method.
This commit is contained in:
commit
d78fbb6ad4
|
@ -26,7 +26,6 @@ bool cmGetDirectoryPropertyCommand
|
||||||
std::vector<std::string>::const_iterator i = args.begin();
|
std::vector<std::string>::const_iterator i = args.begin();
|
||||||
std::string variable = *i;
|
std::string variable = *i;
|
||||||
++i;
|
++i;
|
||||||
std::string output = "";
|
|
||||||
|
|
||||||
// get the directory argument if there is one
|
// get the directory argument if there is one
|
||||||
cmMakefile *dir = this->Makefile;
|
cmMakefile *dir = this->Makefile;
|
||||||
|
@ -79,7 +78,7 @@ bool cmGetDirectoryPropertyCommand
|
||||||
"providing the name of the variable to get.");
|
"providing the name of the variable to get.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
output = dir->GetSafeDefinition(*i);
|
std::string output = dir->GetSafeDefinition(*i);
|
||||||
this->Makefile->AddDefinition(variable, output.c_str());
|
this->Makefile->AddDefinition(variable, output.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -87,14 +86,37 @@ bool cmGetDirectoryPropertyCommand
|
||||||
const char *prop = 0;
|
const char *prop = 0;
|
||||||
if (!i->empty())
|
if (!i->empty())
|
||||||
{
|
{
|
||||||
|
if (*i == "DEFINITIONS")
|
||||||
|
{
|
||||||
|
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0059))
|
||||||
|
{
|
||||||
|
case cmPolicies::WARN:
|
||||||
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
|
cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
|
||||||
|
case cmPolicies::OLD:
|
||||||
|
this->StoreResult(variable,
|
||||||
|
this->Makefile->GetDefineFlagsCMP0059());
|
||||||
|
return true;
|
||||||
|
case cmPolicies::NEW:
|
||||||
|
case cmPolicies::REQUIRED_ALWAYS:
|
||||||
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
prop = dir->GetProperty(*i);
|
prop = dir->GetProperty(*i);
|
||||||
}
|
}
|
||||||
if (prop)
|
this->StoreResult(variable, prop);
|
||||||
{
|
|
||||||
this->Makefile->AddDefinition(variable, prop);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
this->Makefile->AddDefinition(variable, "");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmGetDirectoryPropertyCommand::StoreResult(std::string const& variable,
|
||||||
|
const char* prop)
|
||||||
|
{
|
||||||
|
if (prop)
|
||||||
|
{
|
||||||
|
this->Makefile->AddDefinition(variable, prop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->Makefile->AddDefinition(variable, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,9 @@ public:
|
||||||
virtual std::string GetName() const { return "get_directory_property";}
|
virtual std::string GetName() const { return "get_directory_property";}
|
||||||
|
|
||||||
cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand);
|
cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void StoreResult(const std::string& variable, const char* prop);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -279,6 +279,22 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->PropertyName == "DEFINITIONS")
|
||||||
|
{
|
||||||
|
switch(mf->GetPolicyStatus(cmPolicies::CMP0059))
|
||||||
|
{
|
||||||
|
case cmPolicies::WARN:
|
||||||
|
mf->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
|
cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
|
||||||
|
case cmPolicies::OLD:
|
||||||
|
return this->StoreResult(mf->GetDefineFlagsCMP0059());
|
||||||
|
case cmPolicies::NEW:
|
||||||
|
case cmPolicies::REQUIRED_ALWAYS:
|
||||||
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the property.
|
// Get the property.
|
||||||
return this->StoreResult(mf->GetProperty(this->PropertyName));
|
return this->StoreResult(mf->GetProperty(this->PropertyName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4171,22 +4171,6 @@ const char *cmMakefile::GetProperty(const std::string& prop,
|
||||||
this->GetListOfMacros(output);
|
this->GetListOfMacros(output);
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
else if (prop == "DEFINITIONS")
|
|
||||||
{
|
|
||||||
switch(this->GetPolicyStatus(cmPolicies::CMP0059))
|
|
||||||
{
|
|
||||||
case cmPolicies::WARN:
|
|
||||||
this->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::
|
|
||||||
GetPolicyWarning(cmPolicies::CMP0059));
|
|
||||||
case cmPolicies::OLD:
|
|
||||||
output += this->DefineFlagsOrig;
|
|
||||||
return output.c_str();
|
|
||||||
case cmPolicies::NEW:
|
|
||||||
case cmPolicies::REQUIRED_ALWAYS:
|
|
||||||
case cmPolicies::REQUIRED_IF_USED:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (prop == "LINK_DIRECTORIES")
|
else if (prop == "LINK_DIRECTORIES")
|
||||||
{
|
{
|
||||||
output = cmJoin(this->GetLinkDirectories(), ";");
|
output = cmJoin(this->GetLinkDirectories(), ";");
|
||||||
|
@ -4674,6 +4658,11 @@ cmState::Snapshot cmMakefile::GetStateSnapshot() const
|
||||||
return this->StateSnapshot;
|
return this->StateSnapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* cmMakefile::GetDefineFlagsCMP0059() const
|
||||||
|
{
|
||||||
|
return this->DefineFlagsOrig.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmPolicies::PolicyStatus
|
cmPolicies::PolicyStatus
|
||||||
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
|
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
|
||||||
|
|
|
@ -838,6 +838,8 @@ public:
|
||||||
|
|
||||||
cmState::Snapshot GetStateSnapshot() const;
|
cmState::Snapshot GetStateSnapshot() const;
|
||||||
|
|
||||||
|
const char* GetDefineFlagsCMP0059() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// add link libraries and directories to the target
|
// add link libraries and directories to the target
|
||||||
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
|
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
|
||||||
|
|
Loading…
Reference in New Issue