summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYury G. Kudryashov <urkud.urkud@gmail.com>2012-02-29 22:02:56 (GMT)
committerBrad King <brad.king@kitware.com>2012-09-28 13:21:39 (GMT)
commit5c898fbd99f6d12e8835a0dd3b229d93812e7533 (patch)
treecffbfe8c6c48f4762dbd01d2edb51c7b1f50f9a8
parentd13ec1ac31518d5c7875e9fa8b849e42ed66a3a3 (diff)
downloadCMake-5c898fbd99f6d12e8835a0dd3b229d93812e7533.zip
CMake-5c898fbd99f6d12e8835a0dd3b229d93812e7533.tar.gz
CMake-5c898fbd99f6d12e8835a0dd3b229d93812e7533.tar.bz2
exports: Add cmExportSetMap class
This is a map<string, cmExportSet *> with overloaded operator[] and destructor.
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/cmExportSetMap.cxx34
-rw-r--r--Source/cmExportSetMap.h33
-rw-r--r--Source/cmGlobalGenerator.cxx29
-rw-r--r--Source/cmGlobalGenerator.h10
-rw-r--r--Source/cmInstallCommand.cxx3
-rw-r--r--Source/cmInstallExportGenerator.cxx2
-rwxr-xr-xbootstrap1
8 files changed, 76 insertions, 38 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index e04b7c9..186aa6d 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -178,6 +178,8 @@ set(SRCS
cmExportInstallFileGenerator.cxx
cmExportSet.h
cmExportSet.cxx
+ cmExportSetMap.h
+ cmExportSetMap.cxx
cmExtraCodeBlocksGenerator.cxx
cmExtraCodeBlocksGenerator.h
cmExtraEclipseCDT4Generator.cxx
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
new file mode 100644
index 0000000..96fdb3e
--- /dev/null
+++ b/Source/cmExportSetMap.cxx
@@ -0,0 +1,34 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmExportSetMap.h"
+#include "cmExportSet.h"
+
+cmExportSet* cmExportSetMap::operator[](const std::string &name)
+{
+ std::map<std::string, cmExportSet*>::iterator it = this->find(name);
+ if (it == this->end()) // Export set not found
+ {
+ it = this->insert(std::make_pair(name, new cmExportSet(name))).first;
+ }
+ return it->second;
+}
+
+cmExportSetMap::~cmExportSetMap()
+{
+ for(std::map<std::string, cmExportSet*>::iterator it = this->begin();
+ it != this->end();
+ ++ it)
+ {
+ delete it->second;
+ }
+}
diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h
new file mode 100644
index 0000000..4663c55
--- /dev/null
+++ b/Source/cmExportSetMap.h
@@ -0,0 +1,33 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmExportSetMap_h
+#define cmExportSetMap_h
+
+#include "cmSystemTools.h"
+class cmExportSet;
+
+/// A name -> cmExportSet map with overloaded operator[].
+class cmExportSetMap : public std::map<std::string, cmExportSet*>
+{
+public:
+ /** \brief Overloaded operator[].
+ *
+ * The operator is overloaded because cmExportSet has no default constructor:
+ * we do not want unnamed export sets.
+ */
+ cmExportSet* operator[](const std::string &name);
+
+ /// Overloaded destructor deletes all member export sets.
+ ~cmExportSetMap();
+};
+
+#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5640af9..e464381 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1467,35 +1467,6 @@ void cmGlobalGenerator::AddInstallComponent(const char* component)
}
}
-void cmGlobalGenerator::AddTargetToExport(const char* exportSetName,
- cmTargetExport const* te)
-{
- std::map<cmStdString, cmExportSet>::iterator it = ExportSets.find(exportSetName);
- // If EXPORT named exportSetName does not exist, create it.
- if (it == ExportSets.end())
- {
- cmStdString key = exportSetName;
- cmExportSet value(key);
- it = ExportSets.insert(std::make_pair(key, value)).first;
- }
- it->second.AddTargetExport(te);
-}
-
-//----------------------------------------------------------------------------
-
-const cmExportSet *cmGlobalGenerator::GetExportSet(const char* name) const
-{
- std::map<cmStdString, cmExportSet >::const_iterator
- exportSetIt = this->ExportSets.find(name);
- if (exportSetIt != this->ExportSets.end())
- {
- return &exportSetIt->second;
- }
-
- return 0;
-}
-
-
void cmGlobalGenerator::EnableInstallTarget()
{
this->InstallTargetEnabled = true;
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 568e138..71c3a4d 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -18,14 +18,13 @@
#include "cmTarget.h" // For cmTargets
#include "cmTargetDepend.h" // For cmTargetDependSet
#include "cmSystemTools.h" // for cmSystemTools::OutputOption
-#include "cmExportSet.h" // For cmExportSet
+#include "cmExportSetMap.h" // For cmExportSetMap
class cmake;
class cmGeneratorTarget;
class cmMakefile;
class cmLocalGenerator;
class cmExternalMakefileProjectGenerator;
class cmTarget;
-class cmTargetExport;
class cmInstallTargetGenerator;
class cmInstallFilesGenerator;
@@ -154,10 +153,7 @@ public:
const std::set<cmStdString>* GetInstallComponents() const
{ return &this->InstallComponents; }
- ///! Add one installed target to the sets of the exports
- void AddTargetToExport(const char* exportSet, cmTargetExport const* te);
- ///! Get the export target set with the given name
- const cmExportSet *GetExportSet(const char* name) const;
+ cmExportSetMap& GetExportSets() {return this->ExportSets;}
/** Add a file to the manifest of generated targets for a configuration. */
void AddToManifest(const char* config, std::string const& f);
@@ -329,7 +325,7 @@ protected:
std::set<cmStdString> InstallComponents;
bool InstallTargetEnabled;
// Sets of named target exports
- std::map<cmStdString, cmExportSet> ExportSets;
+ cmExportSetMap ExportSets;
// Manifest of all targets that will be built for each configuration.
// This is computed just before local generators generate.
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 62fc2ef..6eaa103 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -18,6 +18,7 @@
#include "cmInstallExportGenerator.h"
#include "cmInstallCommandArguments.h"
#include "cmTargetExport.h"
+#include "cmExportSet.h"
#include <cmsys/Glob.hxx>
@@ -745,7 +746,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
te->LibraryGenerator = libraryGenerator;
te->RuntimeGenerator = runtimeGenerator;
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
- ->AddTargetToExport(exports.GetCString(), te);
+ ->GetExportSets()[exports.GetString()]->AddTargetExport(te);
}
}
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index a9cd3fe..0179cd1 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -117,7 +117,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
// Get the export set requested.
cmExportSet const* exportSet =
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
- ->GetExportSet(this->Name.c_str());
+ ->GetExportSets()[this->Name];
// Skip empty sets.
if(!exportSet)
diff --git a/bootstrap b/bootstrap
index a9e8a86..d51d80f 100755
--- a/bootstrap
+++ b/bootstrap
@@ -200,6 +200,7 @@ CMAKE_CXX_SOURCES="\
cmExportFileGenerator \
cmExportInstallFileGenerator \
cmExportSet \
+ cmExportSetMap \
cmInstallDirectoryGenerator \
cmGeneratedFileStream \
cmGeneratorTarget \