[Cmake-commits] [cmake-commits] king committed cmComputeLinkDepends.cxx 1.19 1.20 cmComputeLinkDepends.h 1.10 1.11 cmComputeTargetDepends.cxx 1.3 1.4 cmComputeTargetDepends.h 1.2 1.3

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Aug 6 17:48:56 EDT 2008


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

Modified Files:
	cmComputeLinkDepends.cxx cmComputeLinkDepends.h 
	cmComputeTargetDepends.cxx cmComputeTargetDepends.h 
Log Message:
BUG: Avoid bogus dependency on executable targets

When an executable target within the project is named in
target_link_libraries for another target, but the executable does not
have the ENABLE_EXPORTS property set, then the executable cannot really
be linked.  This is probably a case where the user intends to link to a
third-party library that happens to have the same name as an executable
target in the project (or else will get an error at build time).  We
need to avoid making the other target depend on the executable target
incorrectly, since the executable may actually want to link to that
target and this is not a circular depenency.


Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C 2 -d -r1.10 -r1.11
*** cmComputeLinkDepends.h	30 Jul 2008 14:23:41 -0000	1.10
--- cmComputeLinkDepends.h	6 Aug 2008 21:48:53 -0000	1.11
***************
*** 86,89 ****
--- 86,90 ----
                        std::vector<std::string> const& libs);
    std::string CleanItemName(std::string const& item);
+   cmTarget* FindTargetToLink(const char* name);
  
    // One entry for each unique item.

Index: cmComputeTargetDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeTargetDepends.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** cmComputeTargetDepends.cxx	6 Aug 2008 21:48:49 -0000	1.3
--- cmComputeTargetDepends.cxx	6 Aug 2008 21:48:53 -0000	1.4
***************
*** 215,219 ****
      if(emitted.insert(lib->first).second)
        {
!       this->AddTargetDepend(depender_index, lib->first.c_str());
        }
      }
--- 215,219 ----
      if(emitted.insert(lib->first).second)
        {
!       this->AddTargetDepend(depender_index, lib->first.c_str(), true);
        }
      }
***************
*** 227,231 ****
      if(emitted.insert(*util).second)
        {
!       this->AddTargetDepend(depender_index, util->c_str());
        }
      }
--- 227,231 ----
      if(emitted.insert(*util).second)
        {
!       this->AddTargetDepend(depender_index, util->c_str(), false);
        }
      }
***************
*** 234,238 ****
  //----------------------------------------------------------------------------
  void cmComputeTargetDepends::AddTargetDepend(int depender_index,
!                                              const char* dependee_name)
  {
    // Get the depender.
--- 234,239 ----
  //----------------------------------------------------------------------------
  void cmComputeTargetDepends::AddTargetDepend(int depender_index,
!                                              const char* dependee_name,
!                                              bool linking)
  {
    // Get the depender.
***************
*** 249,252 ****
--- 250,263 ----
      }
  
+   // Skip targets that will not really be linked.  This is probably a
+   // name conflict between an external library and an executable
+   // within the project.
+   if(linking && dependee &&
+      dependee->GetType() == cmTarget::EXECUTABLE &&
+      !dependee->IsExecutableWithExports())
+     {
+     dependee = 0;
+     }
+ 
    // If not found then skip then the dependee.
    if(!dependee)

Index: cmComputeTargetDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeTargetDepends.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmComputeTargetDepends.h	7 Feb 2008 21:14:05 -0000	1.2
--- cmComputeTargetDepends.h	6 Aug 2008 21:48:53 -0000	1.3
***************
*** 49,53 ****
    void CollectDepends();
    void CollectTargetDepends(int depender_index);
!   void AddTargetDepend(int depender_index, const char* dependee_name);
    void ComputeFinalDepends(cmComputeComponentGraph const& ccg);
  
--- 49,54 ----
    void CollectDepends();
    void CollectTargetDepends(int depender_index);
!   void AddTargetDepend(int depender_index, const char* dependee_name,
!                        bool linking);
    void ComputeFinalDepends(cmComputeComponentGraph const& ccg);
  

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** cmComputeLinkDepends.cxx	30 Jul 2008 14:23:41 -0000	1.19
--- cmComputeLinkDepends.cxx	6 Aug 2008 21:48:53 -0000	1.20
***************
*** 293,297 ****
    LinkEntry& entry = this->EntryList[index];
    entry.Item = item;
!   entry.Target = this->Makefile->FindTargetToUse(entry.Item.c_str());
  
    // If the item has dependencies queue it to follow them.
--- 293,297 ----
    LinkEntry& entry = this->EntryList[index];
    entry.Item = item;
!   entry.Target = this->FindTargetToLink(entry.Item.c_str());
  
    // If the item has dependencies queue it to follow them.
***************
*** 388,392 ****
      LinkEntry& entry = this->EntryList[lei->second];
      entry.Item = dep.Item;
!     entry.Target = this->Makefile->FindTargetToUse(dep.Item.c_str());
  
      // This item was added specifically because it is a dependent
--- 388,392 ----
      LinkEntry& entry = this->EntryList[lei->second];
      entry.Item = dep.Item;
!     entry.Target = this->FindTargetToLink(dep.Item.c_str());
  
      // This item was added specifically because it is a dependent
***************
*** 656,659 ****
--- 656,678 ----
  
  //----------------------------------------------------------------------------
+ cmTarget* cmComputeLinkDepends::FindTargetToLink(const char* name)
+ {
+   // Look for a target.
+   cmTarget* tgt = this->Makefile->FindTargetToUse(name);
+ 
+   // Skip targets that will not really be linked.  This is probably a
+   // name conflict between an external library and an executable
+   // within the project.
+   if(tgt && tgt->GetType() == cmTarget::EXECUTABLE &&
+      !tgt->IsExecutableWithExports())
+     {
+     tgt = 0;
+     }
+ 
+   // Return the target found, if any.
+   return tgt;
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmComputeLinkDepends::InferDependencies()
  {
***************
*** 863,867 ****
    // directories of targets linked in another configuration as link
    // directories.
!   if(cmTarget* tgt = this->Makefile->FindTargetToUse(item.c_str()))
      {
      if(!tgt->IsImported())
--- 882,886 ----
    // directories of targets linked in another configuration as link
    // directories.
!   if(cmTarget* tgt = this->FindTargetToLink(item.c_str()))
      {
      if(!tgt->IsImported())



More information about the Cmake-commits mailing list