summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorTushar Maheshwari <tushar27192@gmail.com>2019-09-06 10:16:02 (GMT)
committerTushar Maheshwari <tushar27192@gmail.com>2019-09-19 13:50:29 (GMT)
commit9b8a1f7c28deac892493b0a5548b08b2003238ea (patch)
tree72c22cba36879fded9bf99b94e75c2329281a048 /Source
parentcca5897318d5c747078f79cd5bb45ba74955102a (diff)
downloadCMake-9b8a1f7c28deac892493b0a5548b08b2003238ea.zip
CMake-9b8a1f7c28deac892493b0a5548b08b2003238ea.tar.gz
CMake-9b8a1f7c28deac892493b0a5548b08b2003238ea.tar.bz2
cmExportSetMap: improve ownership of cmExportSet
- use `std::piecewise_construct` to fix gcc-4.8 build. - can use `emplace(name, name)` gcc-6 onwards.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportCommand.cxx10
-rw-r--r--Source/cmExportInstallFileGenerator.cxx7
-rw-r--r--Source/cmExportSetMap.cxx22
-rw-r--r--Source/cmExportSetMap.h18
-rw-r--r--Source/cmInstallCommand.cxx12
5 files changed, 22 insertions, 47 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 4046f91..66dcb97 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -121,7 +121,7 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- cmExportSet* ExportSet = nullptr;
+ cmExportSet* exportSet = nullptr;
if (args[0] == "EXPORT") {
cmExportSetMap& setMap = gg->GetExportSets();
auto const it = setMap.find(arguments.ExportSetName);
@@ -131,7 +131,7 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
this->SetError(e.str());
return false;
}
- ExportSet = it->second;
+ exportSet = &it->second;
} else if (!arguments.Targets.empty() ||
cmContains(keywordsMissingValue, "TARGETS")) {
for (std::string const& currentTarget : arguments.Targets) {
@@ -180,8 +180,8 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
ebfg->SetExportFile(fname.c_str());
ebfg->SetNamespace(arguments.Namespace);
ebfg->SetAppendMode(arguments.Append);
- if (ExportSet != nullptr) {
- ebfg->SetExportSet(ExportSet);
+ if (exportSet != nullptr) {
+ ebfg->SetExportSet(exportSet);
} else {
ebfg->SetTargets(targets);
}
@@ -197,7 +197,7 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
for (std::string const& ct : configurationTypes) {
ebfg->AddConfiguration(ct);
}
- if (ExportSet != nullptr) {
+ if (exportSet != nullptr) {
gg->AddBuildExportExportSet(ebfg);
} else {
gg->AddBuildExportSet(ebfg);
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 4e3db09..c5aec64 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -474,9 +474,8 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg,
const cmExportSetMap& exportSets = gg->GetExportSets();
for (auto const& expIt : exportSets) {
- const cmExportSet* exportSet = expIt.second;
- std::vector<cmTargetExport*> const* targets =
- exportSet->GetTargetExports();
+ const cmExportSet& exportSet = expIt.second;
+ std::vector<cmTargetExport*> const* targets = exportSet.GetTargetExports();
bool containsTarget = false;
for (cmTargetExport* target : *targets) {
@@ -488,7 +487,7 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg,
if (containsTarget) {
std::vector<cmInstallExportGenerator const*> const* installs =
- exportSet->GetInstallations();
+ exportSet.GetInstallations();
for (cmInstallExportGenerator const* install : *installs) {
exportFiles.push_back(install->GetDestinationFile());
ns = install->GetNamespace();
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
index 5c3f84f..68e76d5 100644
--- a/Source/cmExportSetMap.cxx
+++ b/Source/cmExportSetMap.cxx
@@ -2,30 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportSetMap.h"
-#include "cmAlgorithms.h"
-#include "cmExportSet.h"
-
+#include <tuple>
#include <utility>
-cmExportSet* cmExportSetMap::operator[](const std::string& name)
+cmExportSet& cmExportSetMap::operator[](const std::string& name)
{
auto it = this->find(name);
if (it == this->end()) // Export set not found
{
- it = this->insert(std::make_pair(name, new cmExportSet(name))).first;
+ auto tup_name = std::make_tuple(name);
+ it = this->emplace(std::piecewise_construct, tup_name, tup_name).first;
}
return it->second;
}
-
-void cmExportSetMap::clear()
-{
- cmDeleteAll(*this);
- this->derived::clear();
-}
-
-cmExportSetMap::cmExportSetMap() = default;
-
-cmExportSetMap::~cmExportSetMap()
-{
- this->clear();
-}
diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h
index 0ef07ef..5764c0b 100644
--- a/Source/cmExportSetMap.h
+++ b/Source/cmExportSetMap.h
@@ -8,12 +8,12 @@
#include <map>
#include <string>
-class cmExportSet;
+#include "cmExportSet.h"
/// A name -> cmExportSet map with overloaded operator[].
-class cmExportSetMap : public std::map<std::string, cmExportSet*>
+class cmExportSetMap : public std::map<std::string, cmExportSet>
{
- using derived = std::map<std::string, cmExportSet*>;
+ using derived = std::map<std::string, cmExportSet>;
public:
/** \brief Overloaded operator[].
@@ -21,17 +21,7 @@ public:
* The operator is overloaded because cmExportSet has no default constructor:
* we do not want unnamed export sets.
*/
- cmExportSet* operator[](const std::string& name);
-
- void clear();
-
- cmExportSetMap();
-
- /// Overloaded destructor deletes all member export sets.
- ~cmExportSetMap();
-
- cmExportSetMap(const cmExportSetMap&) = delete;
- cmExportSetMap& operator=(const cmExportSetMap&) = delete;
+ cmExportSet& operator[](const std::string& name);
};
#endif
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 9b931f7..11d2c4b 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -755,7 +755,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
te->ObjectsGenerator = objectGenerator;
this->Makefile->GetGlobalGenerator()
->GetExportSets()[exports]
- ->AddTargetExport(te);
+ .AddTargetExport(te);
te->InterfaceIncludeDirectories =
cmJoin(includesArgs.GetIncludeDirs(), ";");
@@ -1333,7 +1333,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
fname = "Android.mk";
}
- cmExportSet* exportSet =
+ cmExportSet& exportSet =
this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
cmInstallGenerator::MessageLevel message =
@@ -1341,7 +1341,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
// Create the export install generator.
cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+ &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
ica.GetConfigurations(), ica.GetComponent().c_str(), message,
ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
true);
@@ -1430,10 +1430,10 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
}
}
- cmExportSet* exportSet =
+ cmExportSet& exportSet =
this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
if (exportOld) {
- for (cmTargetExport* te : *exportSet->GetTargetExports()) {
+ for (cmTargetExport* te : *exportSet.GetTargetExports()) {
cmTarget* tgt =
this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
@@ -1457,7 +1457,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Create the export install generator.
cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+ &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
ica.GetConfigurations(), ica.GetComponent().c_str(), message,
ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
false);