summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Maheshwari <tushar27192@gmail.com>2019-09-08 09:14:55 (GMT)
committerTushar Maheshwari <tushar27192@gmail.com>2019-09-19 13:50:29 (GMT)
commit6511fa6f3309984fc10de8471017c2bb32d8d286 (patch)
treefb4b068962d37cc9763fd779f45662edc7fd1179
parent9b8a1f7c28deac892493b0a5548b08b2003238ea (diff)
downloadCMake-6511fa6f3309984fc10de8471017c2bb32d8d286.zip
CMake-6511fa6f3309984fc10de8471017c2bb32d8d286.tar.gz
CMake-6511fa6f3309984fc10de8471017c2bb32d8d286.tar.bz2
cmExportSet: default destructor
-rw-r--r--Source/cmExportBuildFileGenerator.cxx3
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx3
-rw-r--r--Source/cmExportInstallFileGenerator.cxx15
-rw-r--r--Source/cmExportSet.cxx15
-rw-r--r--Source/cmExportSet.h15
-rw-r--r--Source/cmInstallCommand.cxx12
-rw-r--r--Source/cmInstallExportGenerator.cxx2
7 files changed, 34 insertions, 31 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index e9d2412..08c6e7b 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -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;
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index 207ea41..8f7e2dd 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -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;
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index c5aec64..28e8244 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -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;
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index a6fa186..05f1b5d 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -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)
diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h
index d654c12..2eee849 100644
--- a/Source/cmExportSet.h
+++ b/Source/cmExportSet.h
@@ -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;
};
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 11d2c4b..54f6cc6 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -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 =
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 0b3617b..cba68be 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -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()
<< "\"";