summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-22 14:13:04 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-22 14:13:04 (GMT)
commit96fd5909d9dd1ffe740230ce652d574cd01c62d5 (patch)
treee83b3ce2d5066660256a69cacb6caa7d2d95c416 /Source/cmTarget.cxx
parent0df9e6904cd2416336a85d6d7972ce84dcbab417 (diff)
downloadCMake-96fd5909d9dd1ffe740230ce652d574cd01c62d5.zip
CMake-96fd5909d9dd1ffe740230ce652d574cd01c62d5.tar.gz
CMake-96fd5909d9dd1ffe740230ce652d574cd01c62d5.tar.bz2
ENH: Implement linking with paths to library files instead of -L and -l separation. See bug #3832
- This is purely an implementation improvement. No interface has changed. - Create cmComputeLinkInformation class - Move and re-implement logic from: cmLocalGenerator::ComputeLinkInformation cmOrderLinkDirectories - Link libraries to targets with their full path (if it is known) - Dirs specified with link_directories command still added with -L - Make link type specific to library names without paths (name libfoo.a without path becomes -Wl,-Bstatic -lfoo) - Make directory ordering specific to a runtime path computation feature (look for conflicting SONAMEs instead of library names) - Implement proper rpath support on HP-UX and AIX.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx131
1 files changed, 72 insertions, 59 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 787e08e..ab303ab 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -35,7 +35,6 @@ cmTarget::cmTarget()
{
this->Makefile = 0;
this->LinkLibrariesAnalyzed = false;
- this->LinkDirectoriesComputed = false;
this->HaveInstallRule = false;
this->DLLPlatform = false;
this->IsImportedTarget = false;
@@ -843,71 +842,15 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf,
void cmTarget::AddLinkDirectory(const char* d)
{
// Make sure we don't add unnecessary search directories.
- if(std::find(this->ExplicitLinkDirectories.begin(),
- this->ExplicitLinkDirectories.end(), d)
- == this->ExplicitLinkDirectories.end() )
+ if(this->LinkDirectoriesEmmitted.insert(d).second)
{
- this->ExplicitLinkDirectories.push_back( d );
- this->LinkDirectoriesComputed = false;
+ this->LinkDirectories.push_back(d);
}
}
//----------------------------------------------------------------------------
const std::vector<std::string>& cmTarget::GetLinkDirectories()
{
- // Make sure all library dependencies have been analyzed.
- if(!this->LinkLibrariesAnalyzed && !this->LinkLibraries.empty())
- {
- cmSystemTools::Error(
- "cmTarget::GetLinkDirectories called before "
- "cmTarget::AnalyzeLibDependencies on target ",
- this->Name.c_str());
- }
-
- // Make sure the complete set of link directories has been computed.
- if(!this->LinkDirectoriesComputed)
- {
- // Check whether we should use an import library for linking a target.
- bool implib =
- this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX") != 0;
-
- // Compute the full set of link directories including the
- // locations of targets that have been linked in. Start with the
- // link directories given explicitly.
- this->LinkDirectories = this->ExplicitLinkDirectories;
- for(LinkLibraryVectorType::iterator ll = this->LinkLibraries.begin();
- ll != this->LinkLibraries.end(); ++ll)
- {
- // If this library is a CMake target then add its location as a
- // link directory.
- std::string lib = ll->first;
- cmTarget* tgt = 0;
- if(this->Makefile && this->Makefile->GetLocalGenerator() &&
- this->Makefile->GetLocalGenerator()->GetGlobalGenerator())
- {
- tgt = (this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
- ->FindTarget(0, lib.c_str(), false));
- }
- if(tgt)
- {
- // Add the directory only if it is not already present. This
- // is an N^2 algorithm for adding the directories, but N
- // should not get very big.
- const char* libpath = tgt->GetDirectory(0, implib);
- if(std::find(this->LinkDirectories.begin(),
- this->LinkDirectories.end(),
- libpath) == this->LinkDirectories.end())
- {
- this->LinkDirectories.push_back(libpath);
- }
- }
- }
-
- // The complete set of link directories has now been computed.
- this->LinkDirectoriesComputed = true;
- }
-
- // Return the complete set of link directories.
return this->LinkDirectories;
}
@@ -2245,6 +2188,76 @@ void cmTarget::GetExecutableNamesInternal(std::string& name,
}
//----------------------------------------------------------------------------
+void cmTarget::GenerateTargetManifest(const char* config)
+{
+ cmMakefile* mf = this->Makefile;
+ cmLocalGenerator* lg = mf->GetLocalGenerator();
+ cmGlobalGenerator* gg = lg->GetGlobalGenerator();
+
+ // Get the names.
+ std::string name;
+ std::string soName;
+ std::string realName;
+ std::string impName;
+ std::string pdbName;
+ if(this->GetType() == cmTarget::EXECUTABLE)
+ {
+ this->GetExecutableNames(name, realName, impName, pdbName, config);
+ }
+ else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
+ this->GetType() == cmTarget::SHARED_LIBRARY ||
+ this->GetType() == cmTarget::MODULE_LIBRARY)
+ {
+ this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
+ }
+ else
+ {
+ return;
+ }
+
+ // Get the directory.
+ std::string dir = this->GetDirectory(config, false);
+
+ // Add each name.
+ std::string f;
+ if(!name.empty())
+ {
+ f = dir;
+ f += "/";
+ f += name;
+ gg->AddToManifest(config? config:"", f);
+ }
+ if(!soName.empty())
+ {
+ f = dir;
+ f += "/";
+ f += soName;
+ gg->AddToManifest(config? config:"", f);
+ }
+ if(!realName.empty())
+ {
+ f = dir;
+ f += "/";
+ f += realName;
+ gg->AddToManifest(config? config:"", f);
+ }
+ if(!pdbName.empty())
+ {
+ f = dir;
+ f += "/";
+ f += pdbName;
+ gg->AddToManifest(config? config:"", f);
+ }
+ if(!impName.empty())
+ {
+ f = this->GetDirectory(config, true);
+ f += "/";
+ f += impName;
+ gg->AddToManifest(config? config:"", f);
+ }
+}
+
+//----------------------------------------------------------------------------
void cmTarget::SetPropertyDefault(const char* property,
const char* default_value)
{