[Cmake-commits] [cmake-commits] hoffman committed cmComputeLinkInformation.cxx 1.24.2.7 1.24.2.8 cmComputeLinkInformation.h 1.15.2.2 1.15.2.3 cmPolicies.cxx 1.20.2.5 1.20.2.6 cmPolicies.h 1.10.2.3 1.10.2.4 cmTarget.cxx 1.207.2.7 1.207.2.8 cmTarget.h 1.109.2.4 1.109.2.5

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jul 28 11:31:37 EDT 2008


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

Modified Files:
      Tag: CMake-2-6
	cmComputeLinkInformation.cxx cmComputeLinkInformation.h 
	cmPolicies.cxx cmPolicies.h cmTarget.cxx cmTarget.h 
Log Message:
ENH: merge in policy 0008 and cdash direct submission


Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.10.2.3
retrieving revision 1.10.2.4
diff -C 2 -d -r1.10.2.3 -r1.10.2.4
*** cmPolicies.h	23 Apr 2008 02:05:40 -0000	1.10.2.3
--- cmPolicies.h	28 Jul 2008 15:31:35 -0000	1.10.2.4
***************
*** 49,52 ****
--- 49,53 ----
      CMP0006, // BUNDLE install rules needed for MACOSX_BUNDLE targets
      CMP0007, // list command handling of empty elements
+     CMP0008, // Full-path libraries must be a valid library file name
  
      // Always the last entry.  Useful mostly to avoid adding a comma

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.20.2.5
retrieving revision 1.20.2.6
diff -C 2 -d -r1.20.2.5 -r1.20.2.6
*** cmPolicies.cxx	23 Apr 2008 02:05:40 -0000	1.20.2.5
--- cmPolicies.cxx	28 Jul 2008 15:31:35 -0000	1.20.2.6
***************
*** 282,285 ****
--- 282,311 ----
      "elements in a list. ",
      2,6,0, cmPolicies::WARN);
+ 
+   this->DefinePolicy(
+     CMP0008, "CMP0008",
+     "Libraries linked by full-path must have a valid library file name.",
+     "In CMake 2.4 and below it is possible to write code like\n"
+     "  target_link_libraries(myexe /full/path/to/somelib)\n"
+     "where \"somelib\" is supposed to be a valid library file name "
+     "such as \"libsomelib.a\" or \"somelib.lib\".  "
+     "For Makefile generators this produces an error at build time "
+     "because the dependency on the full path cannot be found.  "
+     "For VS IDE and Xcode generators this used to work by accident because "
+     "CMake would always split off the library directory and ask the "
+     "linker to search for the library by name (-lsomelib or somelib.lib).  "
+     "Despite the failure with Makefiles, some projects have code like this "
+     "and build only with VS and/or Xcode.  "
+     "This version of CMake prefers to pass the full path directly to the "
+     "native build tool, which will fail in this case because it does "
+     "not name a valid library file."
+     "\n"
+     "This policy determines what to do with full paths that do not appear "
+     "to name a valid library file.  "
+     "The OLD behavior for this policy is to split the library name from the "
+     "path and ask the linker to search for it.  "
+     "The NEW behavior for this policy is to trust the given path and "
+     "pass it directly to the native build tool unchanged.",
+     2,6,1, cmPolicies::WARN);
  }
  

Index: cmComputeLinkInformation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.h,v
retrieving revision 1.15.2.2
retrieving revision 1.15.2.3
diff -C 2 -d -r1.15.2.2 -r1.15.2.3
*** cmComputeLinkInformation.h	1 May 2008 16:35:39 -0000	1.15.2.2
--- cmComputeLinkInformation.h	28 Jul 2008 15:31:35 -0000	1.15.2.3
***************
*** 140,144 ****
    void AddFullItem(std::string const& item);
    bool CheckImplicitDirItem(std::string const& item);
!   void AddUserItem(std::string const& item);
    void AddDirectoryItem(std::string const& item);
    void AddFrameworkItem(std::string const& item);
--- 140,144 ----
    void AddFullItem(std::string const& item);
    bool CheckImplicitDirItem(std::string const& item);
!   void AddUserItem(std::string const& item, bool pathNotKnown);
    void AddDirectoryItem(std::string const& item);
    void AddFrameworkItem(std::string const& item);
***************
*** 146,149 ****
--- 146,150 ----
    bool CheckSharedLibNoSOName(std::string const& item);
    void AddSharedLibNoSOName(std::string const& item);
+   void HandleBadFullItem(std::string const& item, std::string const& file);
  
    // Framework info.

Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.24.2.7
retrieving revision 1.24.2.8
diff -C 2 -d -r1.24.2.7 -r1.24.2.8
*** cmComputeLinkInformation.cxx	22 Jul 2008 18:04:24 -0000	1.24.2.7
--- cmComputeLinkInformation.cxx	28 Jul 2008 15:31:35 -0000	1.24.2.8
***************
*** 638,642 ****
        {
        // This is a library or option specified by the user.
!       this->AddUserItem(item);
        }
      }
--- 638,642 ----
        {
        // This is a library or option specified by the user.
!       this->AddUserItem(item, true);
        }
      }
***************
*** 1043,1046 ****
--- 1043,1060 ----
      }
  
+   // Full path libraries should specify a valid library file name.
+   // See documentation of CMP0008.
+   if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
+      (strstr(this->GlobalGenerator->GetName(), "Visual Studio") ||
+       strstr(this->GlobalGenerator->GetName(), "Xcode")))
+     {
+     std::string file = cmSystemTools::GetFilenameName(item);
+     if(!this->ExtractAnyLibraryName.find(file.c_str()))
+       {
+       this->HandleBadFullItem(item, file);
+       return;
+       }
+     }
+ 
    // 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
***************
*** 1079,1123 ****
      }
  
-   // Full path libraries should have an extension.  CMake 2.4 would
-   // add the extension after splitting the file off of the directory.
-   // Some existing projects depended on this to build correctly
-   // because they left off the extension of an otherwise full-path
-   // library.  This worked with CMake 2.4 but only for VS IDE builds
-   // because the file-level dependency added to the Makefile would not
-   // be found.  Nevertheless, some projects have this mistake but work
-   // because they build only with the VS IDE.  We need to support them
-   // here by adding the missing extension.
-   std::string final_item = item;
-   if(strstr(this->GlobalGenerator->GetName(), "Visual Studio") &&
-      this->Makefile->NeedBackwardsCompatibility(2,4) &&
-      !cmSystemTools::ComparePath(
-        cmSystemTools::GetFilenameLastExtension(item).c_str(),
-        this->LibLinkSuffix.c_str()))
-     {
-     // Issue the warning at most once.
-     std::string wid = "VSIDE-LINK-EXT-";
-     wid += item;
-     if(!this->Target->GetPropertyAsBool(wid.c_str()))
-       {
-       this->Target->SetProperty(wid.c_str(), "1");
-       cmOStringStream w;
-       w << "Target \"" << this->Target->GetName() << "\" links to "
-         << "full-path item\n"
-         << "  " << item << "\n"
-         << "which does not have the proper link extension \""
-         << this->LibLinkSuffix << "\".  "
-         << "CMake is adding the missing extension because compatibility "
-         << "with CMake 2.4 is currently enabled and this case worked "
-         << "accidentally in that version.  "
-         << "The link extension should be added by the project developer.";
-       this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-       }
- 
-     // Add the missing extension.
-     final_item += this->LibLinkSuffix;
-     }
- 
    // Now add the full path to the library.
!   this->Items.push_back(Item(final_item, true));
  }
  
--- 1093,1098 ----
      }
  
    // Now add the full path to the library.
!   this->Items.push_back(Item(item, true));
  }
  
***************
*** 1156,1165 ****
    // portion.  This will allow the system linker to locate the proper
    // library for the architecture at link time.
!   this->AddUserItem(file);
    return true;
  }
  
  //----------------------------------------------------------------------------
! void cmComputeLinkInformation::AddUserItem(std::string const& item)
  {
    // This is called to handle a link item that does not match a CMake
--- 1131,1141 ----
    // portion.  This will allow the system linker to locate the proper
    // library for the architecture at link time.
!   this->AddUserItem(file, false);
    return true;
  }
  
  //----------------------------------------------------------------------------
! void cmComputeLinkInformation::AddUserItem(std::string const& item,
!                                            bool pathNotKnown)
  {
    // This is called to handle a link item that does not match a CMake
***************
*** 1251,1255 ****
      {
      // This is a name specified by the user.
!     this->OldUserFlagItems.push_back(item);
  
      // We must ask the linker to search for a library with this name.
--- 1227,1234 ----
      {
      // This is a name specified by the user.
!     if(pathNotKnown)
!       {
!       this->OldUserFlagItems.push_back(item);
!       }
  
      // We must ask the linker to search for a library with this name.
***************
*** 1374,1378 ****
    // path instead of just the name.
    std::string file = cmSystemTools::GetFilenameName(item);
!   this->AddUserItem(file);
  
    // Make sure the link directory ordering will find the library.
--- 1353,1357 ----
    // path instead of just the name.
    std::string file = cmSystemTools::GetFilenameName(item);
!   this->AddUserItem(file, false);
  
    // Make sure the link directory ordering will find the library.
***************
*** 1381,1384 ****
--- 1360,1416 ----
  
  //----------------------------------------------------------------------------
+ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
+                                                  std::string const& file)
+ {
+   // Tell the linker to search for the item and provide the proper
+   // path for it.  Do not contribute to any CMP0003 warning (do not
+   // put in OldLinkDirItems or OldUserFlagItems).
+   this->AddUserItem(file, false);
+   this->OrderLinkerSearchPath->AddLinkLibrary(item);
+ 
+   // Produce any needed message.
+   switch(this->Target->GetPolicyStatusCMP0008())
+     {
+     case cmPolicies::WARN:
+       {
+       // Print the warning at most once for this item.
+       std::string wid = "CMP0008-WARNING-GIVEN-";
+       wid += item;
+       if(!this->CMakeInstance->GetPropertyAsBool(wid.c_str()))
+         {
+         this->CMakeInstance->SetProperty(wid.c_str(), "1");
+         cmOStringStream w;
+         w << (this->Makefile->GetPolicies()
+               ->GetPolicyWarning(cmPolicies::CMP0008)) << "\n"
+           << "Target \"" << this->Target->GetName() << "\" links to item\n"
+           << "  " << item << "\n"
+           << "which is a full-path but not a valid library file name.";
+         this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
+                                           this->Target->GetBacktrace());
+         }
+       }
+     case cmPolicies::OLD:
+       // OLD behavior does not warn.
+       break;
+     case cmPolicies::NEW:
+       // NEW behavior will not get here.
+       break;
+     case cmPolicies::REQUIRED_IF_USED:
+     case cmPolicies::REQUIRED_ALWAYS:
+       {
+       cmOStringStream e;
+       e << (this->Makefile->GetPolicies()->
+             GetRequiredPolicyError(cmPolicies::CMP0008)) << "\n"
+           << "Target \"" << this->Target->GetName() << "\" links to item\n"
+           << "  " << item << "\n"
+           << "which is a full-path but not a valid library file name.";
+       this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                         this->Target->GetBacktrace());
+       }
+       break;
+     }
+ }
+ 
+ //----------------------------------------------------------------------------
  bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
  {

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.109.2.4
retrieving revision 1.109.2.5
diff -C 2 -d -r1.109.2.4 -r1.109.2.5
*** cmTarget.h	15 May 2008 19:39:57 -0000	1.109.2.4
--- cmTarget.h	28 Jul 2008 15:31:35 -0000	1.109.2.5
***************
*** 115,118 ****
--- 115,122 ----
      { return this->PolicyStatusCMP0004; }
  
+   /** Get the status of policy CMP0008 when the target was created.  */
+   cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const
+     { return this->PolicyStatusCMP0008; }
+ 
    /**
     * Get the list of the custom commands for this target
***************
*** 548,551 ****
--- 552,556 ----
    cmPolicies::PolicyStatus PolicyStatusCMP0003;
    cmPolicies::PolicyStatus PolicyStatusCMP0004;
+   cmPolicies::PolicyStatus PolicyStatusCMP0008;
  
    // Internal representation details.

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.207.2.7
retrieving revision 1.207.2.8
diff -C 2 -d -r1.207.2.7 -r1.207.2.8
*** cmTarget.cxx	23 May 2008 20:09:39 -0000	1.207.2.7
--- cmTarget.cxx	28 Jul 2008 15:31:35 -0000	1.207.2.8
***************
*** 56,59 ****
--- 56,60 ----
    this->PolicyStatusCMP0003 = cmPolicies::WARN;
    this->PolicyStatusCMP0004 = cmPolicies::WARN;
+   this->PolicyStatusCMP0008 = cmPolicies::WARN;
    this->LinkLibrariesAnalyzed = false;
    this->HaveInstallRule = false;
***************
*** 769,772 ****
--- 770,775 ----
    this->PolicyStatusCMP0004 =
      this->Makefile->GetPolicyStatus(cmPolicies::CMP0004);
+   this->PolicyStatusCMP0008 =
+     this->Makefile->GetPolicyStatus(cmPolicies::CMP0008);
  }
  



More information about the Cmake-commits mailing list