diff options
author | Brad King <brad.king@kitware.com> | 2008-01-29 20:07:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-29 20:07:33 (GMT) |
commit | ffac622a858cca4dc661caa896d961da666430cc (patch) | |
tree | 3c52af43de45021dbfc5afc7f64f3ce17701a78f /Source/cmTarget.cxx | |
parent | bb52f45ebb6b1c80f8f7b8e2b841202118ed9d06 (diff) | |
download | CMake-ffac622a858cca4dc661caa896d961da666430cc.zip CMake-ffac622a858cca4dc661caa896d961da666430cc.tar.gz CMake-ffac622a858cca4dc661caa896d961da666430cc.tar.bz2 |
ENH: Add cmTarget::GetLinkInformation method to allow several places in the generators to share link information while only computing it once per configuration for a target. Use it to simplify the chrpath feature.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a6bf5d2..3691c47 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -20,6 +20,7 @@ #include "cmSourceFile.h" #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" +#include "cmComputeLinkInformation.h" #include <map> #include <set> #include <queue> @@ -41,6 +42,17 @@ 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 @@ -2531,12 +2543,6 @@ bool cmTarget::NeedRelinkBeforeInstall() return false; } - if(this->Makefile->IsOn("CMAKE_USE_CHRPATH") - && (this->IsChrpathAvailable())) - { - return false; - } - // If skipping all rpaths completely then no relinking is needed. if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) { @@ -2549,6 +2555,12 @@ bool cmTarget::NeedRelinkBeforeInstall() return false; } + // If chrpath is going to be used no relinking is needed. + if(this->IsChrpathUsed()) + { + return false; + } + // Check for rpath support on this platform. if(const char* ll = this->GetLinkerLanguage( this->Makefile->GetLocalGenerator()->GetGlobalGenerator())) @@ -2809,35 +2821,28 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const } } -bool cmTarget::IsChrpathAvailable() +//---------------------------------------------------------------------------- +bool cmTarget::IsChrpathUsed() { - //only return true if chrpath has been found (happens only if the executable - // format is ELF) and if the separator is not empty - if (this->Makefile->IsSet("CMAKE_CHRPATH")==false) - { - return false; - } - - const char* linkLanguage = this->GetLinkerLanguage(this->Makefile-> - GetLocalGenerator()->GetGlobalGenerator()); - if (linkLanguage==0) - { - return false; - } - - std::string runTimeFlagSepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - runTimeFlagSepVar += linkLanguage; - runTimeFlagSepVar += "_FLAG_SEP"; - - std::string runtimeSep = - this->Makefile->GetSafeDefinition(runTimeFlagSepVar.c_str()); - - if (runtimeSep.size()<=0) + // Enable use of "chrpath" if it is available, the user has turned + // on the feature, and the rpath flag uses a separator. + if(const char* ll = this->GetLinkerLanguage( + this->Makefile->GetLocalGenerator()->GetGlobalGenerator())) { - return 0; + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar.c_str()); + if(sep && *sep) + { + if(this->Makefile->IsSet("CMAKE_CHRPATH") && + this->Makefile->IsOn("CMAKE_USE_CHRPATH")) + { + return true; + } + } } - - return true; + return false; } //---------------------------------------------------------------------------- @@ -3044,3 +3049,29 @@ cmTarget::GetImportedLinkLibraries(const char* config) return 0; } } + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmTarget::GetLinkInformation(const char* config) +{ + // Lookup any existing information for this configuration. + std::map<cmStdString, cmComputeLinkInformation*>::iterator + i = this->LinkInformation.find(config?config:""); + 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. + std::map<cmStdString, cmComputeLinkInformation*>::value_type + entry(config?config:"", info); + i = this->LinkInformation.insert(entry).first; + } + return i->second; +} |