[Cmake-commits] [cmake-commits] king committed cmComputeLinkDepends.cxx 1.31 1.32 cmComputeLinkDepends.h 1.17 1.18 cmExportFileGenerator.cxx 1.15 1.16 cmExportFileGenerator.h 1.8 1.9 cmTarget.cxx 1.249 1.250 cmTarget.h 1.129 1.130

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jul 6 16:25:22 EDT 2009


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

Modified Files:
	cmComputeLinkDepends.cxx cmComputeLinkDepends.h 
	cmExportFileGenerator.cxx cmExportFileGenerator.h cmTarget.cxx 
	cmTarget.h 
Log Message:
ENH: Centralize default link interface computation

When LINK_INTERFACE_LIBRARIES is not set we use the link implementation
to implicitly define the link interface.  These changes centralize the
decision so that all linkable targets internally have a link interface.


Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C 2 -d -r1.17 -r1.18
*** cmComputeLinkDepends.h	6 Jul 2009 20:24:45 -0000	1.17
--- cmComputeLinkDepends.h	6 Jul 2009 20:25:19 -0000	1.18
***************
*** 84,89 ****
    int AddLinkEntry(int depender_index, std::string const& item);
    void AddVarLinkEntries(int depender_index, const char* value);
!   void AddTargetLinkEntries(int depender_index,
!                             LinkLibraryVectorType const& libs);
    void AddLinkEntries(int depender_index,
                        std::vector<std::string> const& libs);
--- 84,88 ----
    int AddLinkEntry(int depender_index, std::string const& item);
    void AddVarLinkEntries(int depender_index, const char* value);
!   void AddDirectLinkEntries();
    void AddLinkEntries(int depender_index,
                        std::vector<std::string> const& libs);

Index: cmExportFileGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportFileGenerator.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C 2 -d -r1.8 -r1.9
*** cmExportFileGenerator.h	1 Feb 2008 13:56:00 -0000	1.8
--- cmExportFileGenerator.h	6 Jul 2009 20:25:20 -0000	1.9
***************
*** 68,74 ****
                                   std::string const& suffix, cmTarget* target,
                                   ImportPropertyMap& properties);
-   void SetImportLinkProperties(const char* config,
-                                std::string const& suffix, cmTarget* target,
-                                ImportPropertyMap& properties);
    void SetImportLinkProperty(std::string const& suffix,
                               cmTarget* target, const char* propName,
--- 68,71 ----

Index: cmExportFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportFileGenerator.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -C 2 -d -r1.15 -r1.16
*** cmExportFileGenerator.cxx	4 Sep 2008 21:34:24 -0000	1.15
--- cmExportFileGenerator.cxx	6 Jul 2009 20:25:19 -0000	1.16
***************
*** 151,158 ****
  
    // Add the transitive link dependencies for this configuration.
!   if(cmTargetLinkInterface const* iface =
!      target->GetLinkInterface(config))
      {
-     // This target provides a link interface, so use it.
      this->SetImportLinkProperty(suffix, target,
                                  "IMPORTED_LINK_INTERFACE_LIBRARIES",
--- 151,156 ----
  
    // Add the transitive link dependencies for this configuration.
!   if(cmTargetLinkInterface const* iface = target->GetLinkInterface(config))
      {
      this->SetImportLinkProperty(suffix, target,
                                  "IMPORTED_LINK_INTERFACE_LIBRARIES",
***************
*** 162,206 ****
                                  iface->SharedDeps, properties);
      }
-   else if(target->GetType() == cmTarget::STATIC_LIBRARY ||
-           target->GetType() == cmTarget::SHARED_LIBRARY)
-     {
-     // The default link interface for static and shared libraries is
-     // their link implementation library list.
-     this->SetImportLinkProperties(config, suffix, target, properties);
-     }
- }
- 
- //----------------------------------------------------------------------------
- void
- cmExportFileGenerator
- ::SetImportLinkProperties(const char* config, std::string const& suffix,
-                           cmTarget* target, ImportPropertyMap& properties)
- {
-   // Compute which library configuration to link.
-   cmTarget::LinkLibraryType linkType = target->ComputeLinkType(config);
- 
-   // Construct the list of libs linked for this configuration.
-   std::vector<std::string> actual_libs;
-   cmTarget::LinkLibraryVectorType const& libs =
-     target->GetOriginalLinkLibraries();
-   for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
-       li != libs.end(); ++li)
-     {
-     // Skip entries that will resolve to the target itself, are empty,
-     // or are not meant for this configuration.
-     if(li->first == target->GetName() || li->first.empty() ||
-        !(li->second == cmTarget::GENERAL || li->second == linkType))
-       {
-       continue;
-       }
- 
-     // Store this entry.
-     actual_libs.push_back(li->first);
-     }
- 
-   // Store the entries in the property.
-   this->SetImportLinkProperty(suffix, target,
-                               "IMPORTED_LINK_INTERFACE_LIBRARIES",
-                               actual_libs, properties);
  }
  
--- 160,163 ----

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -C 2 -d -r1.31 -r1.32
*** cmComputeLinkDepends.cxx	6 Jul 2009 20:24:45 -0000	1.31
--- cmComputeLinkDepends.cxx	6 Jul 2009 20:25:19 -0000	1.32
***************
*** 224,228 ****
  {
    // Follow the link dependencies of the target to be linked.
!   this->AddTargetLinkEntries(-1, this->Target->GetOriginalLinkLibraries());
  
    // Complete the breadth-first search of dependencies.
--- 224,228 ----
  {
    // Follow the link dependencies of the target to be linked.
!   this->AddDirectLinkEntries();
  
    // Complete the breadth-first search of dependencies.
***************
*** 365,375 ****
        // Handle dependent shared libraries.
        this->QueueSharedDependencies(depender_index, iface->SharedDeps);
!       }
!     else if(!entry.Target->IsImported() &&
!             entry.Target->GetType() != cmTarget::EXECUTABLE)
!       {
!       // Use the target's link implementation as the interface.
!       this->AddTargetLinkEntries(depender_index,
!                                  entry.Target->GetOriginalLinkLibraries());
        }
      }
--- 365,376 ----
        // Handle dependent shared libraries.
        this->QueueSharedDependencies(depender_index, iface->SharedDeps);
! 
!       // Support for CMP0003.
!       for(std::vector<std::string>::const_iterator
!             oi = iface->WrongConfigLibraries.begin();
!           oi != iface->WrongConfigLibraries.end(); ++oi)
!         {
!         this->CheckWrongConfigItem(depender_index, *oi);
!         }
        }
      }
***************
*** 517,525 ****
  
  //----------------------------------------------------------------------------
! void
! cmComputeLinkDepends::AddTargetLinkEntries(int depender_index,
!                                            LinkLibraryVectorType const& libs)
  {
!   // Look for entries meant for this configuration.
    std::vector<std::string> actual_libs;
    for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
--- 518,526 ----
  
  //----------------------------------------------------------------------------
! void cmComputeLinkDepends::AddDirectLinkEntries()
  {
!   // Add direct link dependencies in this configuration.
!   int depender_index = -1;
!   LinkLibraryVectorType const& libs=this->Target->GetOriginalLinkLibraries();
    std::vector<std::string> actual_libs;
    for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
***************
*** 535,540 ****
        }
      }
- 
-   // Add these entries.
    this->AddLinkEntries(depender_index, actual_libs);
  }
--- 536,539 ----

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.129
retrieving revision 1.130
diff -C 2 -d -r1.129 -r1.130
*** cmTarget.h	6 Jul 2009 20:24:45 -0000	1.129
--- cmTarget.h	6 Jul 2009 20:25:20 -0000	1.130
***************
*** 47,50 ****
--- 47,54 ----
    // Shared library dependencies needed for linking on some platforms.
    std::vector<std::string> SharedDeps;
+ 
+   // Libraries listed for other configurations.
+   // Needed only for OLD behavior of CMP0003.
+   std::vector<std::string> WrongConfigLibraries;
  };
  

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.249
retrieving revision 1.250
diff -C 2 -d -r1.249 -r1.250
*** cmTarget.cxx	6 Jul 2009 20:24:45 -0000	1.249
--- cmTarget.cxx	6 Jul 2009 20:25:20 -0000	1.250
***************
*** 3683,3690 ****
      }
  
!   // Link interfaces are supported only for shared libraries and
!   // executables that export symbols.
!   if((this->GetType() != cmTarget::SHARED_LIBRARY &&
!       !this->IsExecutableWithExports()))
      {
      return 0;
--- 3683,3690 ----
      }
  
!   // Link interfaces are not supported for executables that do not
!   // export symbols.
!   if(this->GetType() == cmTarget::EXECUTABLE &&
!      !this->IsExecutableWithExports())
      {
      return 0;
***************
*** 3725,3745 ****
      }
  
!   // Lookup the link interface libraries.
!   const char* libs = 0;
!   {
!   // Lookup the per-configuration property.
!   std::string propName = "LINK_INTERFACE_LIBRARIES";
!   propName += suffix;
!   libs = this->GetProperty(propName.c_str());
! 
!   // If not set, try the generic property.
!   if(!libs)
      {
!     libs = this->GetProperty("LINK_INTERFACE_LIBRARIES");
      }
-   }
  
!   // If still not set, there is no link interface.
!   if(!libs)
      {
      return cmsys::auto_ptr<cmTargetLinkInterface>();
--- 3725,3749 ----
      }
  
!   // An explicit list of interface libraries may be set for shared
!   // libraries and executables that export symbols.
!   const char* explicitLibraries = 0;
!   if(this->GetType() == cmTarget::SHARED_LIBRARY ||
!      this->IsExecutableWithExports())
      {
!     // Lookup the per-configuration property.
!     std::string propName = "LINK_INTERFACE_LIBRARIES";
!     propName += suffix;
!     explicitLibraries = this->GetProperty(propName.c_str());
! 
!     // If not set, try the generic property.
!     if(!explicitLibraries)
!       {
!       explicitLibraries = this->GetProperty("LINK_INTERFACE_LIBRARIES");
!       }
      }
  
!   // There is no implicit link interface for executables, so if none
!   // was explicitly set, there is no link interface.
!   if(!explicitLibraries && this->GetType() == cmTarget::EXECUTABLE)
      {
      return cmsys::auto_ptr<cmTargetLinkInterface>();
***************
*** 3753,3773 ****
      }
  
!   // Expand the list of libraries in the interface.
!   cmSystemTools::ExpandListArgument(libs, iface->Libraries);
  
!   // Now we need to construct a list of shared library dependencies
!   // not included in the interface.
!   if(this->GetType() == cmTarget::SHARED_LIBRARY)
      {
!     // Use a set to keep track of what libraries have been emitted to
!     // either list.
!     std::set<cmStdString> emitted;
      for(std::vector<std::string>::const_iterator
!           li = iface->Libraries.begin();
!         li != iface->Libraries.end(); ++li)
        {
        emitted.insert(*li);
        }
  
      // Compute which library configuration to link.
      cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
--- 3757,3785 ----
      }
  
!   // Is the link interface just the link implementation?
!   bool doLibraries = !explicitLibraries;
  
!   // Do we need to construct a list of shared library dependencies not
!   // included in the interface?
!   bool doSharedDeps = (explicitLibraries &&
!                        this->GetType() == cmTarget::SHARED_LIBRARY);
! 
!   // Keep track of what libraries have been emitted.
!   std::set<cmStdString> emitted;
!   std::set<cmStdString> emittedWrongConfig;
! 
!   if(explicitLibraries)
      {
!     // The interface libraries have been explicitly set.
!     cmSystemTools::ExpandListArgument(explicitLibraries, iface->Libraries);
      for(std::vector<std::string>::const_iterator
!           li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li)
        {
        emitted.insert(*li);
        }
+     }
  
+   if(doLibraries || doSharedDeps)
+     {
      // Compute which library configuration to link.
      cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
***************
*** 3779,3802 ****
          li != llibs.end(); ++li)
        {
!       // Skip entries that will resolve to the target itself, are empty,
!       // or are not meant for this configuration.
!       if(li->first == this->GetName() || li->first.empty() ||
!          !(li->second == cmTarget::GENERAL || li->second == linkType))
          {
          continue;
          }
  
!       // Skip entries that have already been emitted into either list.
!       if(!emitted.insert(li->first).second)
          {
          continue;
          }
  
!       // Add this entry if it is a shared library.
!       if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->first.c_str()))
          {
          if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
            {
!           iface->SharedDeps.push_back(li->first);
            }
          }
--- 3791,3830 ----
          li != llibs.end(); ++li)
        {
!       // Skip entries that resolve to the target itself or are empty.
!       std::string item = this->CheckCMP0004(li->first);
!       if(item == this->GetName() || item.empty())
          {
          continue;
          }
  
!       // Skip entries not meant for this configuration.
!       if(li->second != cmTarget::GENERAL && li->second != linkType)
          {
+         // Support OLD behavior for CMP0003.
+         if(doLibraries && !emittedWrongConfig.insert(item).second)
+           {
+           iface->WrongConfigLibraries.push_back(item);
+           }
          continue;
          }
  
!       // Skip entries that have already been emitted.
!       if(!emitted.insert(item).second)
          {
+         continue;
+         }
+ 
+       // Emit this item.
+       if(doLibraries)
+         {
+         // This implementation dependency goes in the implicit interface.
+         iface->Libraries.push_back(item);
+         }
+       else if(cmTarget* tgt = this->Makefile->FindTargetToUse(item.c_str()))
+         {
+         // This is a runtime dependency on another shared library.
          if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
            {
!           iface->SharedDeps.push_back(item);
            }
          }



More information about the Cmake-commits mailing list