[cmake-commits] king committed cmComputeLinkInformation.cxx 1.1 1.2 cmComputeLinkInformation.h 1.1 1.2

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jan 22 10:05:29 EST 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv31817/Source

Modified Files:
	cmComputeLinkInformation.cxx cmComputeLinkInformation.h 
Log Message:
BUG: When a library file name is linked without a path make sure the link type is restored after the -l option.


Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmComputeLinkInformation.cxx	22 Jan 2008 14:13:03 -0000	1.1
+++ cmComputeLinkInformation.cxx	22 Jan 2008 15:05:27 -0000	1.2
@@ -337,7 +337,7 @@
       else
 #endif
         {
-        this->Items.push_back(Item(lib, true));
+        this->AddTargetItem(lib, tgt);
         this->AddLibraryRuntimeInfo(lib, tgt);
         }
       }
@@ -355,8 +355,8 @@
       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::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

Index: cmComputeLinkInformation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmComputeLinkInformation.h	22 Jan 2008 14:13:03 -0000	1.1
+++ cmComputeLinkInformation.h	22 Jan 2008 15:05:27 -0000	1.2
@@ -102,6 +102,8 @@
   std::string NoCaseExpression(const char* str);
 
   // Handling of link items that are not targets or full file paths.
+  void AddTargetItem(std::string const& item, cmTarget* target);
+  void AddFullItem(std::string const& item);
   void AddUserItem(std::string const& item);
   void AddDirectoryItem(std::string const& item);
   void AddFrameworkItem(std::string const& item);



More information about the Cmake-commits mailing list