summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYury G. Kudryashov <urkud.urkud@gmail.com>2012-02-27 06:09:40 (GMT)
committerBrad King <brad.king@kitware.com>2012-09-28 13:21:39 (GMT)
commitd13ec1ac31518d5c7875e9fa8b849e42ed66a3a3 (patch)
tree7c3cadb9d2241b8087b0fffa03efff39e3311d52
parent4e2347cbf39ab72f9bf4ca8bdac7dbecd0143dde (diff)
downloadCMake-d13ec1ac31518d5c7875e9fa8b849e42ed66a3a3.zip
CMake-d13ec1ac31518d5c7875e9fa8b849e42ed66a3a3.tar.gz
CMake-d13ec1ac31518d5c7875e9fa8b849e42ed66a3a3.tar.bz2
exports: Create class cmExportSet
Replace direct use of 'std::vector<cmTargetExport const*>' with a dedicated class.
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/cmExportInstallFileGenerator.cxx17
-rw-r--r--Source/cmExportInstallFileGenerator.h5
-rw-r--r--Source/cmExportSet.cxx27
-rw-r--r--Source/cmExportSet.h38
-rw-r--r--Source/cmGlobalGenerator.cxx36
-rw-r--r--Source/cmGlobalGenerator.h8
-rw-r--r--Source/cmInstallExportGenerator.cxx3
-rw-r--r--Source/cmInstallExportGenerator.h9
-rwxr-xr-xbootstrap1
10 files changed, 103 insertions, 43 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index cf0d8d2..e04b7c9 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -176,6 +176,8 @@ set(SRCS
cmExportFileGenerator.cxx
cmExportInstallFileGenerator.h
cmExportInstallFileGenerator.cxx
+ cmExportSet.h
+ cmExportSet.cxx
cmExtraCodeBlocksGenerator.cxx
cmExtraCodeBlocksGenerator.h
cmExtraEclipseCDT4Generator.cxx
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 1e35c61..ba8b1839 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -15,6 +15,7 @@
#include "cmInstallExportGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmTargetExport.h"
+#include "cmExportSet.h"
//----------------------------------------------------------------------------
cmExportInstallFileGenerator
@@ -36,11 +37,11 @@ std::string cmExportInstallFileGenerator::GetConfigImportFileGlob()
bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
// Create all the imported targets.
- for(std::vector<cmTargetExport*>::const_iterator
- tei = this->ExportSet->begin();
- tei != this->ExportSet->end(); ++tei)
+ for(std::vector<cmTargetExport const*>::const_iterator
+ tei = this->ExportSet->GetTargetExports()->begin();
+ tei != this->ExportSet->GetTargetExports()->end(); ++tei)
{
- cmTargetExport* te = *tei;
+ cmTargetExport const* te = *tei;
if(this->ExportedTargets.insert(te->Target).second)
{
this->GenerateImportTargetCode(os, te->Target);
@@ -161,12 +162,12 @@ cmExportInstallFileGenerator
}
// Add each target in the set to the export.
- for(std::vector<cmTargetExport*>::const_iterator
- tei = this->ExportSet->begin();
- tei != this->ExportSet->end(); ++tei)
+ for(std::vector<cmTargetExport const*>::const_iterator
+ tei = this->ExportSet->GetTargetExports()->begin();
+ tei != this->ExportSet->GetTargetExports()->end(); ++tei)
{
// Collect import properties for this target.
- cmTargetExport* te = *tei;
+ cmTargetExport const* te = *tei;
ImportPropertyMap properties;
std::set<std::string> importedLocations;
this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator,
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index ce37515..7b86b16 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -18,6 +18,7 @@ class cmInstallExportGenerator;
class cmInstallFilesGenerator;
class cmInstallTargetGenerator;
class cmTargetExport;
+class cmExportSet;
/** \class cmExportInstallFileGenerator
* \brief Generate a file exporting targets from an install tree.
@@ -46,7 +47,7 @@ public:
/** Set the set of targets to be exported. These are the targets
associated with the export name. */
- void SetExportSet(std::vector<cmTargetExport*> const* eSet)
+ void SetExportSet(cmExportSet const* eSet)
{ this->ExportSet = eSet; }
/** Get the per-config file generated for each configuraiton. This
@@ -83,7 +84,7 @@ protected:
cmInstallExportGenerator* InstallExportGenerator;
std::string Name;
- std::vector<cmTargetExport*> const* ExportSet;
+ cmExportSet const* ExportSet;
std::string ImportPrefix;
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
new file mode 100644
index 0000000..b86e147
--- /dev/null
+++ b/Source/cmExportSet.cxx
@@ -0,0 +1,27 @@
+/*============================================================================
+ 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 "cmExportSet.h"
+#include "cmTargetExport.h"
+
+cmExportSet::~cmExportSet()
+{
+ for(unsigned int i = 0; i < this->TargetExports.size(); ++ i)
+ {
+ delete this->TargetExports[i];
+ }
+}
+
+void cmExportSet::AddTargetExport(cmTargetExport const* te)
+{
+ this->TargetExports.push_back(te);
+}
diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h
new file mode 100644
index 0000000..5d4d25f
--- /dev/null
+++ b/Source/cmExportSet.h
@@ -0,0 +1,38 @@
+/*============================================================================
+ 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 cmExportSet_h
+#define cmExportSet_h
+
+#include "cmSystemTools.h"
+class cmTargetExport;
+
+/// A set of targets that were installed with the same EXPORT parameter.
+class cmExportSet
+{
+public:
+ /// Construct an empty export set named \a name
+ cmExportSet(const std::string &name) : Name(name) {}
+ /// Destructor
+ ~cmExportSet();
+
+ void AddTargetExport(cmTargetExport const* tgt);
+
+ std::string const& GetName() const { return this->Name; }
+ std::vector<cmTargetExport const*> const* GetTargetExports() const
+ { return &this->TargetExports; }
+
+private:
+ std::vector<cmTargetExport const*> TargetExports;
+ std::string Name;
+};
+
+#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 15edfec..5640af9 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -76,12 +76,13 @@ cmGlobalGenerator::~cmGlobalGenerator()
}
this->ClearGeneratorTargets();
- this->ClearExportSets();
+ this->ExportSets.clear();
}
void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
cmMakefile *mf,
- bool optional) {
+ bool optional)
+{
std::string langComp = "CMAKE_";
langComp += lang;
langComp += "_COMPILER";
@@ -817,7 +818,7 @@ void cmGlobalGenerator::Configure()
{
this->FirstTimeProgress = 0.0f;
this->ClearGeneratorTargets();
- this->ClearExportSets();
+ this->ExportSets.clear();
// Delete any existing cmLocalGenerators
unsigned int i;
for (i = 0; i < this->LocalGenerators.size(); ++i)
@@ -1467,33 +1468,24 @@ void cmGlobalGenerator::AddInstallComponent(const char* component)
}
void cmGlobalGenerator::AddTargetToExport(const char* exportSetName,
- cmTargetExport *te)
+ cmTargetExport const* te)
{
- if ((exportSetName) && (*exportSetName) && (te))
+ std::map<cmStdString, cmExportSet>::iterator it = ExportSets.find(exportSetName);
+ // If EXPORT named exportSetName does not exist, create it.
+ if (it == ExportSets.end())
{
- this->ExportSets[exportSetName].push_back(te);
+ cmStdString key = exportSetName;
+ cmExportSet value(key);
+ it = ExportSets.insert(std::make_pair(key, value)).first;
}
+ it->second.AddTargetExport(te);
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::ClearExportSets()
-{
- for(std::map<cmStdString, std::vector<cmTargetExport*> >::iterator
- setIt = this->ExportSets.begin();
- setIt != this->ExportSets.end(); ++setIt)
- {
- for(unsigned int i = 0; i < setIt->second.size(); ++i)
- {
- delete setIt->second[i];
- }
- }
- this->ExportSets.clear();
-}
-const std::vector<cmTargetExport*>* cmGlobalGenerator::GetExportSet(
- const char* name) const
+const cmExportSet *cmGlobalGenerator::GetExportSet(const char* name) const
{
- std::map<cmStdString, std::vector<cmTargetExport*> >::const_iterator
+ std::map<cmStdString, cmExportSet >::const_iterator
exportSetIt = this->ExportSets.find(name);
if (exportSetIt != this->ExportSets.end())
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 5408c7e..568e138 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -18,6 +18,7 @@
#include "cmTarget.h" // For cmTargets
#include "cmTargetDepend.h" // For cmTargetDependSet
#include "cmSystemTools.h" // for cmSystemTools::OutputOption
+#include "cmExportSet.h" // For cmExportSet
class cmake;
class cmGeneratorTarget;
class cmMakefile;
@@ -154,9 +155,9 @@ public:
{ return &this->InstallComponents; }
///! Add one installed target to the sets of the exports
- void AddTargetToExport(const char* exportSet, cmTargetExport* te);
+ void AddTargetToExport(const char* exportSet, cmTargetExport const* te);
///! Get the export target set with the given name
- const std::vector<cmTargetExport*>* GetExportSet(const char* name) const;
+ const cmExportSet *GetExportSet(const char* name) const;
/** Add a file to the manifest of generated targets for a configuration. */
void AddToManifest(const char* config, std::string const& f);
@@ -328,8 +329,7 @@ protected:
std::set<cmStdString> InstallComponents;
bool InstallTargetEnabled;
// Sets of named target exports
- std::map<cmStdString, std::vector<cmTargetExport*> > ExportSets;
- void ClearExportSets();
+ std::map<cmStdString, cmExportSet> ExportSets;
// Manifest of all targets that will be built for each configuration.
// This is computed just before local generators generate.
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 28a19d7..a9cd3fe 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -23,6 +23,7 @@
#include "cmInstallFilesGenerator.h"
#include "cmExportInstallFileGenerator.h"
+#include "cmExportSet.h"
//----------------------------------------------------------------------------
cmInstallExportGenerator::cmInstallExportGenerator(
@@ -114,7 +115,7 @@ void cmInstallExportGenerator::ComputeTempDir()
void cmInstallExportGenerator::GenerateScript(std::ostream& os)
{
// Get the export set requested.
- ExportSet const* exportSet =
+ cmExportSet const* exportSet =
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->GetExportSet(this->Name.c_str());
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index 1ff6e38..7b65ab7 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -17,8 +17,7 @@
class cmExportInstallFileGenerator;
class cmInstallFilesGenerator;
class cmInstallTargetGenerator;
-class cmTarget;
-class cmTargetExport;
+class cmExportSet;
class cmMakefile;
/** \class cmInstallExportGenerator
@@ -35,13 +34,11 @@ public:
cmMakefile* mf);
~cmInstallExportGenerator();
protected:
- typedef std::vector<cmTargetExport*> ExportSet;
-
virtual void GenerateScript(std::ostream& os);
virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
- void GenerateImportFile(ExportSet const* exportSet);
- void GenerateImportFile(const char* config, ExportSet const* exportSet);
+ void GenerateImportFile(cmExportSet const* exportSet);
+ void GenerateImportFile(const char* config, cmExportSet const* exportSet);
void ComputeTempDir();
std::string Name;
diff --git a/bootstrap b/bootstrap
index ec5745d..a9e8a86 100755
--- a/bootstrap
+++ b/bootstrap
@@ -199,6 +199,7 @@ CMAKE_CXX_SOURCES="\
cmMakefile \
cmExportFileGenerator \
cmExportInstallFileGenerator \
+ cmExportSet \
cmInstallDirectoryGenerator \
cmGeneratedFileStream \
cmGeneratorTarget \