cmExportSet: default destructor

This commit is contained in:
Tushar Maheshwari
2019-09-08 14:44:55 +05:30
parent 9b8a1f7c28
commit 6511fa6f33
7 changed files with 34 additions and 31 deletions

View File

@@ -283,7 +283,8 @@ void cmExportBuildFileGenerator::GetTargets(
std::vector<std::string>& targets) const
{
if (this->ExportSet) {
for (cmTargetExport* te : *this->ExportSet->GetTargetExports()) {
for (std::unique_ptr<cmTargetExport> const& te :
this->ExportSet->GetTargetExports()) {
targets.push_back(te->TargetName);
}
return;

View File

@@ -35,7 +35,8 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
}
os << "_IMPORT_PREFIX := "
<< "$(LOCAL_PATH)" << path << "\n\n";
for (cmTargetExport* te : *this->IEGen->GetExportSet()->GetTargetExports()) {
for (std::unique_ptr<cmTargetExport> const& te :
this->IEGen->GetExportSet()->GetTargetExports()) {
// Collect import properties for this target.
if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;

View File

@@ -40,12 +40,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
std::string expectedTargets;
std::string sep;
for (cmTargetExport* te :
*this->IEGen->GetExportSet()->GetTargetExports()) {
for (std::unique_ptr<cmTargetExport> const& te :
this->IEGen->GetExportSet()->GetTargetExports()) {
expectedTargets += sep + this->Namespace + te->Target->GetExportName();
sep = " ";
if (this->ExportedTargets.insert(te->Target).second) {
allTargets.push_back(te);
allTargets.push_back(te.get());
} else {
std::ostringstream e;
e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
@@ -314,9 +314,11 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
std::vector<std::string>& missingTargets)
{
// Add each target in the set to the export.
for (cmTargetExport* te : *this->IEGen->GetExportSet()->GetTargetExports()) {
for (std::unique_ptr<cmTargetExport> const& te :
this->IEGen->GetExportSet()->GetTargetExports()) {
// Collect import properties for this target.
if (this->GetExportTargetType(te) == cmStateEnums::INTERFACE_LIBRARY) {
if (this->GetExportTargetType(te.get()) ==
cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -475,10 +477,9 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg,
for (auto const& expIt : exportSets) {
const cmExportSet& exportSet = expIt.second;
std::vector<cmTargetExport*> const* targets = exportSet.GetTargetExports();
bool containsTarget = false;
for (cmTargetExport* target : *targets) {
for (auto const& target : exportSet.GetTargetExports()) {
if (name == target->TargetName) {
containsTarget = true;
break;

View File

@@ -2,25 +2,28 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportSet.h"
#include "cmAlgorithms.h"
#include <utility>
#include "cmLocalGenerator.h"
#include "cmTargetExport.h"
cmExportSet::~cmExportSet()
cmExportSet::cmExportSet(std::string name)
: Name(std::move(name))
{
cmDeleteAll(this->TargetExports);
}
cmExportSet::~cmExportSet() = default;
void cmExportSet::Compute(cmLocalGenerator* lg)
{
for (cmTargetExport* tgtExport : this->TargetExports) {
for (std::unique_ptr<cmTargetExport>& tgtExport : this->TargetExports) {
tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName);
}
}
void cmExportSet::AddTargetExport(cmTargetExport* te)
void cmExportSet::AddTargetExport(std::unique_ptr<cmTargetExport> te)
{
this->TargetExports.push_back(te);
this->TargetExports.emplace_back(std::move(te));
}
void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation)

View File

@@ -5,8 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
#include <vector>
class cmInstallExportGenerator;
@@ -18,10 +18,7 @@ class cmExportSet
{
public:
/// Construct an empty export set named \a name
cmExportSet(std::string name)
: Name(std::move(name))
{
}
cmExportSet(std::string name);
/// Destructor
~cmExportSet();
@@ -30,15 +27,15 @@ public:
void Compute(cmLocalGenerator* lg);
void AddTargetExport(cmTargetExport* tgt);
void AddTargetExport(std::unique_ptr<cmTargetExport> tgt);
void AddInstallation(cmInstallExportGenerator const* installation);
std::string const& GetName() const { return this->Name; }
std::vector<cmTargetExport*> const* GetTargetExports() const
std::vector<std::unique_ptr<cmTargetExport>> const& GetTargetExports() const
{
return &this->TargetExports;
return this->TargetExports;
}
std::vector<cmInstallExportGenerator const*> const* GetInstallations() const
@@ -47,7 +44,7 @@ public:
}
private:
std::vector<cmTargetExport*> TargetExports;
std::vector<std::unique_ptr<cmTargetExport>> TargetExports;
std::string Name;
std::vector<cmInstallExportGenerator const*> Installations;
};

View File

@@ -744,7 +744,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Add this install rule to an export if one was specified and
// this is not a namelink-only rule.
if (!exports.empty() && !namelinkOnly) {
cmTargetExport* te = new cmTargetExport;
auto te = cm::make_unique<cmTargetExport>();
te->TargetName = target.GetName();
te->ArchiveGenerator = archiveGenerator;
te->BundleGenerator = bundleGenerator;
@@ -753,12 +753,12 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
te->LibraryGenerator = libraryGenerator;
te->RuntimeGenerator = runtimeGenerator;
te->ObjectsGenerator = objectGenerator;
this->Makefile->GetGlobalGenerator()
->GetExportSets()[exports]
.AddTargetExport(te);
te->InterfaceIncludeDirectories =
cmJoin(includesArgs.GetIncludeDirs(), ";");
this->Makefile->GetGlobalGenerator()
->GetExportSets()[exports]
.AddTargetExport(std::move(te));
}
}
@@ -1433,7 +1433,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
cmExportSet& exportSet =
this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
if (exportOld) {
for (cmTargetExport* te : *exportSet.GetTargetExports()) {
for (auto const& te : exportSet.GetTargetExports()) {
cmTarget* tgt =
this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =

View File

@@ -123,7 +123,7 @@ size_t cmInstallExportGenerator::GetMaxConfigLength() const
void cmInstallExportGenerator::GenerateScript(std::ostream& os)
{
// Skip empty sets.
if (ExportSet->GetTargetExports()->empty()) {
if (ExportSet->GetTargetExports().empty()) {
std::ostringstream e;
e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
<< "\"";