1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmInstalledFile.h"
7 #include "cmGeneratorExpression.h"
8 #include "cmListFileCache.h"
9 #include "cmMakefile.h"
10 #include "cmStringAlgorithms.h"
13 cmInstalledFile::cmInstalledFile() = default;
15 cmInstalledFile::~cmInstalledFile() = default;
17 cmInstalledFile::Property::Property() = default;
19 cmInstalledFile::Property::~Property() = default;
21 void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
23 cmListFileBacktrace backtrace = mf->GetBacktrace();
24 cmGeneratorExpression ge(backtrace);
27 this->NameExpression = ge.Parse(name);
30 std::string const& cmInstalledFile::GetName() const
35 cmCompiledGeneratorExpression const& cmInstalledFile::GetNameExpression() const
37 return *(this->NameExpression);
40 void cmInstalledFile::RemoveProperty(const std::string& prop)
42 this->Properties.erase(prop);
45 void cmInstalledFile::SetProperty(cmMakefile const* mf,
46 const std::string& prop,
47 const std::string& value)
49 this->RemoveProperty(prop);
50 this->AppendProperty(mf, prop, value);
53 void cmInstalledFile::AppendProperty(cmMakefile const* mf,
54 const std::string& prop,
55 const std::string& value,
58 cmListFileBacktrace backtrace = mf->GetBacktrace();
59 cmGeneratorExpression ge(backtrace);
61 Property& property = this->Properties[prop];
62 property.ValueExpressions.push_back(ge.Parse(value));
65 bool cmInstalledFile::HasProperty(const std::string& prop) const
67 return this->Properties.find(prop) != this->Properties.end();
70 bool cmInstalledFile::GetProperty(const std::string& prop,
71 std::string& value) const
73 auto i = this->Properties.find(prop);
74 if (i == this->Properties.end()) {
78 Property const& property = i->second;
81 std::string separator;
83 for (const auto& ve : property.ValueExpressions) {
85 output += ve->GetInput();
93 bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const
96 bool isSet = this->GetProperty(prop, value);
97 return isSet && cmIsOn(value);
100 void cmInstalledFile::GetPropertyAsList(const std::string& prop,
101 std::vector<std::string>& list) const
104 this->GetProperty(prop, value);
107 cmExpandList(value, list);