diff options
author | Brad King <brad.king@kitware.com> | 2008-02-06 13:34:44 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-02-06 13:34:44 -0500 |
commit | 07be6bb87b27cc09ee17ae9b6850f00893eb586e (patch) | |
tree | de478766a53a16ab569afee087d6ae4bd58b2b54 /Source | |
parent | a752fc5e8500be8a1fc8f5891374f23d125762a3 (diff) | |
download | cmake-07be6bb87b27cc09ee17ae9b6850f00893eb586e.tar.gz |
ENH: When linking to versioned targets whose real file name is known pass the real name to the linker instead of the symlink name.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 14 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.h | 3 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 51 | ||||
-rw-r--r-- | Source/cmTarget.h | 12 |
4 files changed, 65 insertions, 15 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 10a0653793..a10155c247 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -514,7 +514,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) // platform. Add it now. std::string linkItem; linkItem = this->LoaderFlag; - std::string exe = tgt->GetFullPath(config, this->UseImportLibrary); + std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, + true); linkItem += exe; this->Items.push_back(Item(linkItem, true)); this->Depends.push_back(exe); @@ -527,7 +528,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) (impexe || tgt->GetType() == cmTarget::SHARED_LIBRARY)); // Pass the full path to the target file. - std::string lib = tgt->GetFullPath(config, implib); + std::string lib = tgt->GetFullPath(config, implib, true); this->Depends.push_back(lib); if(tgt->IsFrameworkOnApple()) @@ -1254,14 +1255,13 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, std::string soName = target->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); - // Add the library runtime entry. - this->AddLibraryRuntimeInfo(fullPath, soname); + // Include this library in the runtime path ordering. + this->OrderRuntimeSearchPath->AddLibrary(fullPath, soname); } //---------------------------------------------------------------------------- void -cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - const char* soname) +cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) { // Get the name of the library from the file name. std::string file = cmSystemTools::GetFilenameName(fullPath); @@ -1284,7 +1284,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, } // Include this library in the runtime path ordering. - this->OrderRuntimeSearchPath->AddLibrary(fullPath, soname); + this->OrderRuntimeSearchPath->AddLibrary(fullPath); } //---------------------------------------------------------------------------- diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index be3275c9f6..0145e78c0c 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -162,8 +162,7 @@ private: // Runtime path computation. cmOrderRuntimeDirectories* OrderRuntimeSearchPath; void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); - void AddLibraryRuntimeInfo(std::string const& fullPath, - const char* soname = 0); + void AddLibraryRuntimeInfo(std::string const& fullPath); // Dependent library path computation. cmOrderRuntimeDirectories* OrderDependentRPath; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 32c663864d..4f7c3913e3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2008,6 +2008,40 @@ std::string cmTarget::GetSOName(const char* config) } //---------------------------------------------------------------------------- +std::string cmTarget::NormalGetRealName(const char* config) +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->IsImported()) + { + abort(); + } + + if(this->GetType() == cmTarget::EXECUTABLE) + { + // Compute the real name that will be built. + std::string name; + std::string realName; + std::string impName; + std::string pdbName; + this->GetExecutableNames(name, realName, impName, pdbName, config); + return realName; + } + else + { + // Compute the real name that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); + return realName; + } +} + +//---------------------------------------------------------------------------- std::string cmTarget::GetFullName(const char* config, bool implib) { if(this->IsImported()) @@ -2037,7 +2071,8 @@ void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullPath(const char* config, bool implib) +std::string cmTarget::GetFullPath(const char* config, bool implib, + bool realname) { if(this->IsImported()) { @@ -2045,19 +2080,27 @@ std::string cmTarget::GetFullPath(const char* config, bool implib) } else { - return this->NormalGetFullPath(config, implib); + return this->NormalGetFullPath(config, implib, realname); } } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetFullPath(const char* config, bool implib) +std::string cmTarget::NormalGetFullPath(const char* config, bool implib, + bool realname) { // Start with the output directory for the target. std::string fpath = this->GetDirectory(config, implib); fpath += "/"; // Add the full name of the target. - fpath += this->GetFullName(config, implib); + if(realname) + { + fpath += this->NormalGetRealName(config); + } + else + { + fpath += this->GetFullName(config, implib); + } return fpath; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 5f45c88184..11b7671b8f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -260,7 +260,8 @@ public: /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const char* config=0, bool implib = false); + std::string GetFullPath(const char* config=0, bool implib = false, + bool realname = false); /** Get the names of the library needed to generate a build rule that takes into account shared library version numbers. This @@ -437,7 +438,14 @@ private: const char* NormalGetDirectory(const char* config, bool implib); std::string ImportedGetFullPath(const char* config, bool implib); - std::string NormalGetFullPath(const char* config, bool implib); + std::string NormalGetFullPath(const char* config, bool implib, + bool realname); + + /** Get the real name of the target. Allowed only for non-imported + targets. When a library or executable file is versioned this is + the full versioned name. If the target is not versioned this is + the same as GetFullName. */ + std::string NormalGetRealName(const char* config); private: std::string Name; |