mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
cmGeneratorTarget: Move GetLinkInformation from cmTarget
This commit is contained in:
parent
c971338416
commit
803a7982b4
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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&);
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -6460,37 +6458,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
|
||||
@ -6582,26 +6549,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config,
|
||||
return fpath;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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()
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user