mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
cmPropertyMap: Add GetList method
This commit is contained in:
@@ -363,12 +363,12 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
|
|||||||
|
|
||||||
// Build up the list of properties that may have been specified
|
// Build up the list of properties that may have been specified
|
||||||
Json::Value properties = Json::arrayValue;
|
Json::Value properties = Json::arrayValue;
|
||||||
for (auto& prop : testInfo->GetProperties()) {
|
for (auto& prop : testInfo->GetProperties().GetList()) {
|
||||||
Json::Value entry = Json::objectValue;
|
Json::Value entry = Json::objectValue;
|
||||||
entry[kKEY_KEY] = prop.first;
|
entry[kKEY_KEY] = prop.first;
|
||||||
|
|
||||||
// Remove config variables from the value too.
|
// Remove config variables from the value too.
|
||||||
auto cge_value = ge.Parse(prop.second.GetValue());
|
auto cge_value = ge.Parse(prop.second);
|
||||||
const std::string& processed_value = cge_value->Evaluate(lg, config);
|
const std::string& processed_value = cge_value->Evaluate(lg, config);
|
||||||
entry[kVALUE_KEY] = processed_value;
|
entry[kVALUE_KEY] = processed_value;
|
||||||
properties.append(entry);
|
properties.append(entry);
|
||||||
|
@@ -60,3 +60,13 @@ std::vector<std::string> cmPropertyMap::GetKeys() const
|
|||||||
}
|
}
|
||||||
return keyList;
|
return keyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
|
||||||
|
{
|
||||||
|
std::vector<std::pair<std::string, std::string>> kvList;
|
||||||
|
kvList.reserve(this->size());
|
||||||
|
for (auto const& item : *this) {
|
||||||
|
kvList.emplace_back(item.first, item.second.GetValue());
|
||||||
|
}
|
||||||
|
return kvList;
|
||||||
|
}
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class cmPropertyMap : public std::map<std::string, cmProperty>
|
class cmPropertyMap : public std::map<std::string, cmProperty>
|
||||||
@@ -27,6 +28,9 @@ public:
|
|||||||
// -- Lists
|
// -- Lists
|
||||||
//! Get a sorted list of property keys
|
//! Get a sorted list of property keys
|
||||||
std::vector<std::string> GetKeys() const;
|
std::vector<std::string> GetKeys() const;
|
||||||
|
|
||||||
|
//! Get a sorted by key list of property key,value pairs
|
||||||
|
std::vector<std::pair<std::string, std::string>> GetList() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -117,13 +117,12 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
|
|||||||
os << ")\n";
|
os << ")\n";
|
||||||
|
|
||||||
// Output properties for the test.
|
// Output properties for the test.
|
||||||
cmPropertyMap& pm = this->Test->GetProperties();
|
|
||||||
os << indent << "set_tests_properties(" << this->Test->GetName()
|
os << indent << "set_tests_properties(" << this->Test->GetName()
|
||||||
<< " PROPERTIES ";
|
<< " PROPERTIES ";
|
||||||
for (auto const& i : pm) {
|
for (auto const& i : this->Test->GetProperties().GetList()) {
|
||||||
os << " " << i.first << " "
|
os << " " << i.first << " "
|
||||||
<< cmOutputConverter::EscapeForCMake(
|
<< cmOutputConverter::EscapeForCMake(
|
||||||
ge.Parse(i.second.GetValue())->Evaluate(this->LG, config));
|
ge.Parse(i.second)->Evaluate(this->LG, config));
|
||||||
}
|
}
|
||||||
this->GenerateInternalProperties(os);
|
this->GenerateInternalProperties(os);
|
||||||
os << ")" << std::endl;
|
os << ")" << std::endl;
|
||||||
@@ -173,12 +172,11 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent)
|
|||||||
fout << ")" << std::endl;
|
fout << ")" << std::endl;
|
||||||
|
|
||||||
// Output properties for the test.
|
// Output properties for the test.
|
||||||
cmPropertyMap& pm = this->Test->GetProperties();
|
|
||||||
fout << indent << "set_tests_properties(" << this->Test->GetName()
|
fout << indent << "set_tests_properties(" << this->Test->GetName()
|
||||||
<< " PROPERTIES ";
|
<< " PROPERTIES ";
|
||||||
for (auto const& i : pm) {
|
for (auto const& i : this->Test->GetProperties().GetList()) {
|
||||||
fout << " " << i.first << " "
|
fout << " " << i.first << " "
|
||||||
<< cmOutputConverter::EscapeForCMake(i.second.GetValue());
|
<< cmOutputConverter::EscapeForCMake(i.second);
|
||||||
}
|
}
|
||||||
this->GenerateInternalProperties(fout);
|
this->GenerateInternalProperties(fout);
|
||||||
fout << ")" << std::endl;
|
fout << ")" << std::endl;
|
||||||
|
Reference in New Issue
Block a user