diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-08-04 17:19:42 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-08-05 16:20:44 (GMT) |
commit | 803a7982b4403c690d7b7fa8c49d00a5abae3471 (patch) | |
tree | 0d72f1295e8fa3809bfec1b6402caecca0916eae /Source | |
parent | c971338416d7376d8b710b5c18957f6a800b3de0 (diff) | |
download | CMake-803a7982b4403c690d7b7fa8c49d00a5abae3471.zip CMake-803a7982b4403c690d7b7fa8c49d00a5abae3471.tar.gz CMake-803a7982b4403c690d7b7fa8c49d00a5abae3471.tar.bz2 |
cmGeneratorTarget: Move GetLinkInformation from cmTarget
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 38 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 9 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 53 | ||||
-rw-r--r-- | Source/cmTarget.h | 13 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 |
14 files changed, 72 insertions, 85 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector<std::string> const& frameworks = cli->GetFrameworkPaths(); for(std::vector<std::string>::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector<std::string> dirs; std::set<cmTarget const*> emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set<std::string> &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap; + typedef std::map<std::string, cmComputeLinkInformation*> + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths(); for(std::vector<std::string>::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include <assert.h> @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map<std::string, std::string> install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set<cmTarget const*> const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector<std::string> const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -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() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map<std::string, cmComputeLinkInformation*> -{ - typedef std::map<std::string, cmComputeLinkInformation*> derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error |