diff options
author | Brad King <brad.king@kitware.com> | 2008-01-22 15:05:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-22 15:05:27 (GMT) |
commit | ceb716575e837c35747d78caafec9f38fb7da347 (patch) | |
tree | 4255fae777cb2efe23d3f3f1666ae1ca36e94343 /Source/cmComputeLinkInformation.cxx | |
parent | d2d18fb56584b1446981986a3ab0440cacd42e41 (diff) | |
download | CMake-ceb716575e837c35747d78caafec9f38fb7da347.zip CMake-ceb716575e837c35747d78caafec9f38fb7da347.tar.gz CMake-ceb716575e837c35747d78caafec9f38fb7da347.tar.bz2 |
BUG: When a library file name is linked without a path make sure the link type is restored after the -l option.
Diffstat (limited to 'Source/cmComputeLinkInformation.cxx')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 50f69a2..b7305f4 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -337,7 +337,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item) else #endif { - this->Items.push_back(Item(lib, true)); + this->AddTargetItem(lib, tgt); this->AddLibraryRuntimeInfo(lib, tgt); } } @@ -355,8 +355,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item) else { // Use the full path given to the library file. - this->Items.push_back(Item(item, true)); this->Depends.push_back(item); + this->AddFullItem(item); this->AddLibraryRuntimeInfo(item); } } @@ -608,6 +608,53 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) } //---------------------------------------------------------------------------- +void cmComputeLinkInformation::AddTargetItem(std::string const& item, + cmTarget* 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 + // shared. This is because dynamic-mode linking can handle both + // shared and static libraries but static-mode can handle only + // static libraries. If a previous user item changed the link type + // to static we need to make sure it is back to shared. + if(target->GetType() != cmTarget::STATIC_LIBRARY) + { + this->SetCurrentLinkType(LinkShared); + } + + // Now add the full path to the library. + this->Items.push_back(Item(item, true)); +} + +//---------------------------------------------------------------------------- +void cmComputeLinkInformation::AddFullItem(std::string const& item) +{ + // This is called to handle a link item that is a full path. + // If the target is not a static library make sure the link type is + // shared. This is because dynamic-mode linking can handle both + // shared and static libraries but static-mode can handle only + // static libraries. If a previous user item changed the link type + // to static we need to make sure it is back to shared. + if(this->LinkTypeEnabled) + { + std::string name = cmSystemTools::GetFilenameName(item); + if(this->ExtractSharedLibraryName.find(name)) + { + this->SetCurrentLinkType(LinkShared); + } + else if(!this->ExtractStaticLibraryName.find(item)) + { + // We cannot determine the type. Assume it is the target's + // default type. + this->SetCurrentLinkType(this->StartLinkType); + } + } + + // Now add the full path to the library. + this->Items.push_back(Item(item, true)); +} + +//---------------------------------------------------------------------------- void cmComputeLinkInformation::AddUserItem(std::string const& item) { // This is called to handle a link item that does not match a CMake |