diff options
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.h | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 35 | ||||
-rw-r--r-- | Source/cmTarget.h | 12 |
6 files changed, 38 insertions, 17 deletions
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index c657a0e..a8e7e1b 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -351,7 +351,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, } void cmLocalVisualStudio6Generator -::WriteGroup(const cmSourceGroup *sg, cmTarget target, +::WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const char *libName) { const std::vector<const cmSourceFile *> &sourceFiles = diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index e361a18..22415db 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -91,7 +91,7 @@ private: void AddUtilityCommandHack(cmTarget& target, int count, std::vector<std::string>& depends, const cmCustomCommand& origCommand); - void WriteGroup(const cmSourceGroup *sg, cmTarget target, + void WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const char *libName); std::string CreateTargetRules(cmTarget &target, const char* configName, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5922884..18b5721 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1179,7 +1179,7 @@ cmLocalVisualStudio7GeneratorFCInfo } void cmLocalVisualStudio7Generator -::WriteGroup(const cmSourceGroup *sg, cmTarget target, +::WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, const char *libName, std::vector<std::string> *configs) { diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 34af7f5..11b6736 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -114,7 +114,7 @@ private: void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target); void WriteGroup(const cmSourceGroup *sg, - cmTarget target, std::ostream &fout, + cmTarget& target, std::ostream &fout, const char *libName, std::vector<std::string> *configs); virtual std::string GetTargetDirectory(cmTarget const&) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3691c47..706a45f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -25,6 +25,7 @@ #include <set> #include <queue> #include <stdlib.h> // required for atof +#include <assert.h> const char* cmTarget::TargetTypeNames[] = { "EXECUTABLE", "STATIC_LIBRARY", "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET", @@ -42,17 +43,6 @@ cmTarget::cmTarget() } //---------------------------------------------------------------------------- -cmTarget::~cmTarget() -{ - for(std::map<cmStdString, cmComputeLinkInformation*>::iterator - i = this->LinkInformation.begin(); - i != this->LinkInformation.end(); ++i) - { - delete i->second; - } -} - -//---------------------------------------------------------------------------- void cmTarget::DefineProperties(cmake *cm) { cm->DefineProperty @@ -3075,3 +3065,26 @@ cmTarget::GetLinkInformation(const char* config) } return i->second; } + +//---------------------------------------------------------------------------- +cmTargetLinkInformationMap +::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() +{ + // Ideally cmTarget instances should never be copied. However until + // we can make a sweep to remove that, this copy constructor avoids + // allowing the resources (LinkInformation) from getting copied. In + // the worst case this will lead to extra cmComputeLinkInformation + // instances. We also enforce in debug mode that the map be emptied + // when copied. + static_cast<void>(r); + assert(r.empty()); +} + +//---------------------------------------------------------------------------- +cmTargetLinkInformationMap::~cmTargetLinkInformationMap() +{ + for(derived::iterator i = this->begin(); i != this->end(); ++i) + { + delete i->second; + } +} diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 202190a..37ab203 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -26,6 +26,15 @@ class cmSourceFile; class cmGlobalGenerator; class cmComputeLinkInformation; +struct cmTargetLinkInformationMap: + public std::map<cmStdString, cmComputeLinkInformation*> +{ + typedef std::map<cmStdString, cmComputeLinkInformation*> derived; + cmTargetLinkInformationMap() {} + cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); + ~cmTargetLinkInformationMap(); +}; + /** \class cmTarget * \brief Represent a library or executable target loaded from a makefile. * @@ -36,7 +45,6 @@ class cmTarget { public: cmTarget(); - ~cmTarget(); enum TargetType { EXECUTABLE, STATIC_LIBRARY, SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET, INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY}; @@ -466,7 +474,7 @@ private: ImportInfo const* GetImportInfo(const char* config); void ComputeImportInfo(std::string const& desired_config, ImportInfo& info); - std::map<cmStdString, cmComputeLinkInformation*> LinkInformation; + cmTargetLinkInformationMap LinkInformation; // The cmMakefile instance that owns this target. This should // always be set. |