summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-09-15 18:09:10 (GMT)
committerBrad King <brad.king@kitware.com>2006-09-15 18:09:10 (GMT)
commit1d0502927c32cb3a14c101da16d7ab97901dc2a2 (patch)
treea42fea8061717baf973c3d1588f7ca0f136aa3d1 /Source/cmLocalGenerator.cxx
parent429571bd1f35541f1d5c64d3d46bdc2e6b0a95ac (diff)
downloadCMake-1d0502927c32cb3a14c101da16d7ab97901dc2a2.zip
CMake-1d0502927c32cb3a14c101da16d7ab97901dc2a2.tar.gz
CMake-1d0502927c32cb3a14c101da16d7ab97901dc2a2.tar.bz2
ENH: Adding support to link specifically to an archive or a shared library based on the file name specified. This fixes the problem of having -lfoo linking to libfoo.so even when it came from libfoo.a being specified.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx50
1 files changed, 48 insertions, 2 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e1d25b5..26840fb 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1639,14 +1639,60 @@ void cmLocalGenerator
const std::vector<std::string>&
linkDirectories = target.GetLinkDirectories();
+ // Get the language used for linking.
+ const char* linkLanguage =
+ target.GetLinkerLanguage(this->GetGlobalGenerator());
+ if(!linkLanguage)
+ {
+ cmSystemTools::
+ Error("CMake can not determine linker language for target:",
+ target.GetName());
+ return;
+ }
+
+ // Lookup link type selection flags.
+ const char* static_link_type_flag = 0;
+ const char* shared_link_type_flag = 0;
+ const char* target_type_str = 0;
+ switch(target.GetType())
+ {
+ case cmTarget::EXECUTABLE: target_type_str = "EXE"; break;
+ case cmTarget::SHARED_LIBRARY: target_type_str = "SHARED_LIBRARY"; break;
+ case cmTarget::MODULE_LIBRARY: target_type_str = "SHARED_MODULE"; break;
+ default: break;
+ }
+ if(target_type_str)
+ {
+ std::string static_link_type_flag_var = "CMAKE_";
+ static_link_type_flag_var += target_type_str;
+ static_link_type_flag_var += "_LINK_STATIC_";
+ static_link_type_flag_var += linkLanguage;
+ static_link_type_flag_var += "_FLAGS";
+ static_link_type_flag =
+ this->Makefile->GetDefinition(static_link_type_flag_var.c_str());
+
+ std::string shared_link_type_flag_var = "CMAKE_";
+ shared_link_type_flag_var += target_type_str;
+ shared_link_type_flag_var += "_LINK_DYNAMIC_";
+ shared_link_type_flag_var += linkLanguage;
+ shared_link_type_flag_var += "_FLAGS";
+ shared_link_type_flag =
+ this->Makefile->GetDefinition(shared_link_type_flag_var.c_str());
+ }
+
// Compute the link directory order needed to link the libraries.
cmOrderLinkDirectories orderLibs;
+ orderLibs.SetLinkTypeInformation(cmOrderLinkDirectories::LinkShared,
+ static_link_type_flag,
+ shared_link_type_flag);
orderLibs.SetLinkPrefix(
this->Makefile->GetDefinition("CMAKE_STATIC_LIBRARY_PREFIX"));
orderLibs.AddLinkExtension(
- this->Makefile->GetDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"));
+ this->Makefile->GetDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"),
+ cmOrderLinkDirectories::LinkStatic);
orderLibs.AddLinkExtension(
- this->Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"));
+ this->Makefile->GetDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"),
+ cmOrderLinkDirectories::LinkShared);
orderLibs.AddLinkExtension(
this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"));
orderLibs.AddLinkExtension(