2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2014-05-15 17:12:40 +00:00
|
|
|
#include "cmInstalledFile.h"
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2015-03-08 12:37:44 +00:00
|
|
|
#include "cmAlgorithms.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmListFileCache.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSystemTools.h"
|
2014-05-15 17:12:40 +00:00
|
|
|
|
2017-04-11 20:00:21 +00:00
|
|
|
#include "cmConfigure.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmInstalledFile::cmInstalledFile()
|
2016-06-27 20:44:16 +00:00
|
|
|
: NameExpression(CM_NULLPTR)
|
2014-05-15 17:12:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmInstalledFile::~cmInstalledFile()
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (NameExpression) {
|
2014-05-15 17:12:40 +00:00
|
|
|
delete NameExpression;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-05-15 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 12:37:44 +00:00
|
|
|
cmInstalledFile::Property::Property()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmInstalledFile::Property::~Property()
|
|
|
|
{
|
|
|
|
cmDeleteAll(this->ValueExpressions);
|
|
|
|
}
|
|
|
|
|
2014-05-15 17:12:40 +00:00
|
|
|
void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
|
|
|
|
{
|
2014-05-23 18:41:46 +00:00
|
|
|
cmListFileBacktrace backtrace = mf->GetBacktrace();
|
2015-07-08 21:52:51 +00:00
|
|
|
cmGeneratorExpression ge(backtrace);
|
2014-05-15 17:12:40 +00:00
|
|
|
|
|
|
|
this->Name = name;
|
|
|
|
this->NameExpression = ge.Parse(name).release();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const& cmInstalledFile::GetName() const
|
|
|
|
{
|
|
|
|
return this->Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCompiledGeneratorExpression const& cmInstalledFile::GetNameExpression() const
|
|
|
|
{
|
|
|
|
return *(this->NameExpression);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstalledFile::RemoveProperty(const std::string& prop)
|
|
|
|
{
|
|
|
|
this->Properties.erase(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstalledFile::SetProperty(cmMakefile const* mf,
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& prop, const char* value)
|
2014-05-15 17:12:40 +00:00
|
|
|
{
|
|
|
|
this->RemoveProperty(prop);
|
|
|
|
this->AppendProperty(mf, prop, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstalledFile::AppendProperty(cmMakefile const* mf,
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& prop,
|
|
|
|
const char* value, bool /*asString*/)
|
2014-05-15 17:12:40 +00:00
|
|
|
{
|
2014-05-23 18:41:46 +00:00
|
|
|
cmListFileBacktrace backtrace = mf->GetBacktrace();
|
2015-07-08 21:52:51 +00:00
|
|
|
cmGeneratorExpression ge(backtrace);
|
2014-05-15 17:12:40 +00:00
|
|
|
|
|
|
|
Property& property = this->Properties[prop];
|
|
|
|
property.ValueExpressions.push_back(ge.Parse(value).release());
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmInstalledFile::HasProperty(const std::string& prop) const
|
2014-09-27 15:34:39 +00:00
|
|
|
{
|
|
|
|
return this->Properties.find(prop) != this->Properties.end();
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmInstalledFile::GetProperty(const std::string& prop,
|
|
|
|
std::string& value) const
|
2014-05-15 17:12:40 +00:00
|
|
|
{
|
|
|
|
PropertyMapType::const_iterator i = this->Properties.find(prop);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (i == this->Properties.end()) {
|
2014-05-15 17:12:40 +00:00
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-05-15 17:12:40 +00:00
|
|
|
|
|
|
|
Property const& property = i->second;
|
|
|
|
|
|
|
|
std::string output;
|
|
|
|
std::string separator;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
for (ExpressionVectorType::const_iterator j =
|
|
|
|
property.ValueExpressions.begin();
|
|
|
|
j != property.ValueExpressions.end(); ++j) {
|
2014-05-15 17:12:40 +00:00
|
|
|
output += separator;
|
|
|
|
output += (*j)->GetInput();
|
|
|
|
separator = ";";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-05-15 17:12:40 +00:00
|
|
|
|
|
|
|
value = output;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const
|
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
bool isSet = this->GetProperty(prop, value);
|
|
|
|
return isSet && cmSystemTools::IsOn(value.c_str());
|
|
|
|
}
|
2014-08-09 12:50:49 +00:00
|
|
|
|
|
|
|
void cmInstalledFile::GetPropertyAsList(const std::string& prop,
|
2016-05-16 14:34:04 +00:00
|
|
|
std::vector<std::string>& list) const
|
2014-08-09 12:50:49 +00:00
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
this->GetProperty(prop, value);
|
|
|
|
|
|
|
|
list.clear();
|
|
|
|
cmSystemTools::ExpandListArgument(value, list);
|
|
|
|
}
|