Constify handling of link targets.

This commit is contained in:
Stephen Kelly 2013-12-10 15:30:41 +01:00
parent ef25ba8d06
commit 9edee62f28
8 changed files with 41 additions and 34 deletions

View File

@ -619,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index, cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
const char* name) const char* name)
{ {
// Look for a target in the scope of the depender. // Look for a target in the scope of the depender.
cmMakefile* mf = this->Makefile; cmMakefile* mf = this->Makefile;
if(depender_index >= 0) if(depender_index >= 0)
{ {
if(cmTarget* depender = this->EntryList[depender_index].Target) if(cmTarget const* depender = this->EntryList[depender_index].Target)
{ {
mf = depender->GetMakefile(); mf = depender->GetMakefile();
} }
} }
cmTarget* tgt = mf->FindTargetToUse(name); cmTarget const* tgt = mf->FindTargetToUse(name);
// Skip targets that will not really be linked. This is probably a // Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable // name conflict between an external library and an executable
@ -950,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
int count = 2; int count = 2;
for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{ {
if(cmTarget* target = this->EntryList[*ni].Target) if(cmTarget const* target = this->EntryList[*ni].Target)
{ {
if(cmTarget::LinkInterface const* iface = if(cmTarget::LinkInterface const* iface =
target->GetLinkInterface(this->Config, this->HeadTarget)) target->GetLinkInterface(this->Config, this->HeadTarget))
@ -997,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index,
// For CMake 2.4 bug-compatibility we need to consider the output // For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link // directories of targets linked in another configuration as link
// directories. // directories.
if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str())) if(cmTarget const* tgt
= this->FindTargetToLink(depender_index, item.c_str()))
{ {
if(!tgt->IsImported()) if(!tgt->IsImported())
{ {

View File

@ -40,7 +40,7 @@ public:
struct LinkEntry struct LinkEntry
{ {
std::string Item; std::string Item;
cmTarget* Target; cmTarget const* Target;
bool IsSharedDep; bool IsSharedDep;
bool IsFlag; bool IsFlag;
LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {}
@ -53,7 +53,7 @@ public:
EntryVector const& Compute(); EntryVector const& Compute();
void SetOldLinkDirMode(bool b); void SetOldLinkDirMode(bool b);
std::set<cmTarget*> const& GetOldWrongConfigItems() const std::set<cmTarget const*> const& GetOldWrongConfigItems() const
{ return this->OldWrongConfigItems; } { return this->OldWrongConfigItems; }
private: private:
@ -83,7 +83,7 @@ private:
void AddDirectLinkEntries(); void AddDirectLinkEntries();
void AddLinkEntries(int depender_index, void AddLinkEntries(int depender_index,
std::vector<std::string> const& libs); std::vector<std::string> const& libs);
cmTarget* FindTargetToLink(int depender_index, const char* name); cmTarget const* FindTargetToLink(int depender_index, const char* name);
// One entry for each unique item. // One entry for each unique item.
std::vector<LinkEntry> EntryList; std::vector<LinkEntry> EntryList;
@ -164,7 +164,7 @@ private:
// Compatibility help. // Compatibility help.
bool OldLinkDirMode; bool OldLinkDirMode;
void CheckWrongConfigItem(int depender_index, std::string const& item); void CheckWrongConfigItem(int depender_index, std::string const& item);
std::set<cmTarget*> OldWrongConfigItems; std::set<cmTarget const*> OldWrongConfigItems;
}; };
#endif #endif

View File

@ -477,7 +477,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::set<cmTarget*> const& std::set<cmTarget const*> const&
cmComputeLinkInformation::GetSharedLibrariesLinked() cmComputeLinkInformation::GetSharedLibrariesLinked()
{ {
return this->SharedLibrariesLinked; return this->SharedLibrariesLinked;
@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute()
// For CMake 2.4 bug-compatibility we need to consider the output // For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link // directories of targets linked in another configuration as link
// directories. // directories.
std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems(); std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems();
for(std::set<cmTarget*>::const_iterator i = wrongItems.begin(); for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin();
i != wrongItems.end(); ++i) i != wrongItems.end(); ++i)
{ {
cmTarget* tgt = *i; cmTarget const* tgt = *i;
bool implib = bool implib =
(this->UseImportLibrary && (this->UseImportLibrary &&
(tgt->GetType() == cmTarget::SHARED_LIBRARY)); (tgt->GetType() == cmTarget::SHARED_LIBRARY));
@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) void cmComputeLinkInformation::AddItem(std::string const& item,
cmTarget const* tgt)
{ {
// Compute the proper name to use to link this library. // Compute the proper name to use to link this library.
const char* config = this->Config; const char* config = this->Config;
@ -700,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
cmTarget* tgt) cmTarget const* tgt)
{ {
// If dropping shared library dependencies, ignore them. // If dropping shared library dependencies, ignore them.
if(this->SharedDependencyMode == SharedDepModeNone) if(this->SharedDependencyMode == SharedDepModeNone)
@ -1062,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeLinkInformation::AddTargetItem(std::string const& item, void cmComputeLinkInformation::AddTargetItem(std::string const& item,
cmTarget* target) cmTarget const* target)
{ {
// This is called to handle a link item that is a full path to a target. // This is called to handle a link item that is a full path to a target.
// If the target is not a static library make sure the link type is // If the target is not a static library make sure the link type is
@ -1744,7 +1745,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
cmTarget* target) cmTarget const* target)
{ {
// Ignore targets on Apple where install_name is not @rpath. // Ignore targets on Apple where install_name is not @rpath.
// The dependenty library can be found with other means such as // The dependenty library can be found with other means such as

View File

@ -39,11 +39,11 @@ public:
Item(): Value(), IsPath(true), Target(0) {} Item(): Value(), IsPath(true), Target(0) {}
Item(Item const& item): Item(Item const& item):
Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} Value(item.Value), IsPath(item.IsPath), Target(item.Target) {}
Item(std::string const& v, bool p, cmTarget* target = 0): Item(std::string const& v, bool p, cmTarget const* target = 0):
Value(v), IsPath(p), Target(target) {} Value(v), IsPath(p), Target(target) {}
std::string Value; std::string Value;
bool IsPath; bool IsPath;
cmTarget* Target; cmTarget const* Target;
}; };
typedef std::vector<Item> ItemVector; typedef std::vector<Item> ItemVector;
ItemVector const& GetItems(); ItemVector const& GetItems();
@ -57,13 +57,13 @@ public:
void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install); void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
std::string GetRPathString(bool for_install); std::string GetRPathString(bool for_install);
std::string GetChrpathString(); std::string GetChrpathString();
std::set<cmTarget*> const& GetSharedLibrariesLinked(); std::set<cmTarget const*> const& GetSharedLibrariesLinked();
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
std::string GetRPathLinkString(); std::string GetRPathLinkString();
private: private:
void AddItem(std::string const& item, cmTarget* tgt); void AddItem(std::string const& item, cmTarget const* tgt);
void AddSharedDepItem(std::string const& item, cmTarget* tgt); void AddSharedDepItem(std::string const& item, cmTarget const* tgt);
// Output information. // Output information.
ItemVector Items; ItemVector Items;
@ -71,7 +71,7 @@ private:
std::vector<std::string> Depends; std::vector<std::string> Depends;
std::vector<std::string> FrameworkPaths; std::vector<std::string> FrameworkPaths;
std::vector<std::string> RuntimeSearchPath; std::vector<std::string> RuntimeSearchPath;
std::set<cmTarget*> SharedLibrariesLinked; std::set<cmTarget const*> SharedLibrariesLinked;
// Context information. // Context information.
cmTarget const* Target; cmTarget const* Target;
@ -139,7 +139,7 @@ private:
std::string NoCaseExpression(const char* str); std::string NoCaseExpression(const char* str);
// Handling of link items. // Handling of link items.
void AddTargetItem(std::string const& item, cmTarget* target); void AddTargetItem(std::string const& item, cmTarget const* target);
void AddFullItem(std::string const& item); void AddFullItem(std::string const& item);
bool CheckImplicitDirItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item);
void AddUserItem(std::string const& item, bool pathNotKnown); void AddUserItem(std::string const& item, bool pathNotKnown);
@ -179,7 +179,8 @@ private:
// Runtime path computation. // Runtime path computation.
cmOrderDirectories* OrderRuntimeSearchPath; cmOrderDirectories* OrderRuntimeSearchPath;
void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); void AddLibraryRuntimeInfo(std::string const& fullPath,
cmTarget const* target);
void AddLibraryRuntimeInfo(std::string const& fullPath); void AddLibraryRuntimeInfo(std::string const& fullPath);
// Dependent library path computation. // Dependent library path computation.

View File

@ -402,7 +402,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void getPropertyContents(cmTarget *tgt, const char *prop, void getPropertyContents(cmTarget const* tgt, const char *prop,
std::set<std::string> &ifaceProperties) std::set<std::string> &ifaceProperties)
{ {
const char *p = tgt->GetProperty(prop); const char *p = tgt->GetProperty(prop);

View File

@ -328,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, std::string
const char* config, cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
NameType nameType) const char* config,
NameType nameType)
{ {
std::string fname; std::string fname;
// Compute the name of the library. // Compute the name of the library.
@ -515,11 +516,12 @@ cmInstallTargetGenerator
std::map<cmStdString, cmStdString> install_name_remap; std::map<cmStdString, cmStdString> install_name_remap;
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
{ {
std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); std::set<cmTarget const*> const& sharedLibs
for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); = cli->GetSharedLibrariesLinked();
for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin();
j != sharedLibs.end(); ++j) j != sharedLibs.end(); ++j)
{ {
cmTarget* tgt = *j; cmTarget const* tgt = *j;
// The install_name of an imported target does not change. // The install_name of an imported target does not change.
if(tgt->IsImported()) if(tgt->IsImported())

View File

@ -53,7 +53,8 @@ public:
NameReal NameReal
}; };
static std::string GetInstallFilename(cmTarget*target, const char* config, static std::string GetInstallFilename(cmTarget const* target,
const char* config,
NameType nameType = NameNormal); NameType nameType = NameNormal);
cmTarget* GetTarget() const { return this->Target; } cmTarget* GetTarget() const { return this->Target; }

View File

@ -5763,7 +5763,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
template<typename PropertyType> template<typename PropertyType>
void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee, void checkPropertyConsistency(cmTarget const* depender,
cmTarget const* dependee,
const char *propName, const char *propName,
std::set<cmStdString> &emitted, std::set<cmStdString> &emitted,
const char *config, const char *config,