[Cmake-commits] [cmake-commits] king committed cmComputeLinkInformation.cxx 1.30 1.31 cmComputeLinkInformation.h 1.17 1.18 cmPolicies.cxx 1.25 1.26

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Mar 20 21:11:28 EDT 2008


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

Modified Files:
	cmComputeLinkInformation.cxx cmComputeLinkInformation.h 
	cmPolicies.cxx 
Log Message:
ENH: Yet another attempt at warning for CMP0003.

  - Give example code to avoid the warning
  - Make explanation more consise
  - Explicitly state this is for compatibility
  - Issue the warning for at most one target


Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -C 2 -d -r1.30 -r1.31
*** cmComputeLinkInformation.cxx	19 Mar 2008 18:32:38 -0000	1.30
--- cmComputeLinkInformation.cxx	21 Mar 2008 01:11:26 -0000	1.31
***************
*** 1338,1358 ****
      {
      case cmPolicies::WARN:
!       {
!       cmOStringStream w;
!       w << (this->Makefile->GetPolicies()
!             ->GetPolicyWarning(cmPolicies::CMP0003)) << "\n";
!       std::string libs = "CMP0003-WARNING-FOR-";
!       this->PrintLinkPolicyDiagnosis(w, libs);
!       const char* def = this->CMakeInstance->GetCacheDefinition(libs.c_str());
!       if(!def)
          {
          this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
                                            this->Target->GetBacktrace());
-         this->CMakeInstance->AddCacheEntry(libs.c_str(),
-                                            "TRUE",
-                                            "",
-                                            cmCacheManager::INTERNAL);
          }
-       }
      case cmPolicies::OLD:
        // OLD behavior is to add the paths containing libraries with
--- 1338,1349 ----
      {
      case cmPolicies::WARN:
!       if(!this->CMakeInstance->GetPropertyAsBool("CMP0003-WARNING-GIVEN"))
          {
+         this->CMakeInstance->SetProperty("CMP0003-WARNING-GIVEN", "1");
+         cmOStringStream w;
+         this->PrintLinkPolicyDiagnosis(w);
          this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
                                            this->Target->GetBacktrace());
          }
      case cmPolicies::OLD:
        // OLD behavior is to add the paths containing libraries with
***************
*** 1368,1373 ****
        e << (this->Makefile->GetPolicies()->
              GetRequiredPolicyError(cmPolicies::CMP0003)) << "\n";
!       std::string libs;
!       this->PrintLinkPolicyDiagnosis(e, libs);
        this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
                                          this->Target->GetBacktrace());
--- 1359,1363 ----
        e << (this->Makefile->GetPolicies()->
              GetRequiredPolicyError(cmPolicies::CMP0003)) << "\n";
!       this->PrintLinkPolicyDiagnosis(e);
        this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
                                          this->Target->GetBacktrace());
***************
*** 1387,1419 ****
  
  //----------------------------------------------------------------------------
! void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os,
!                                                         std::string& libs)
  {
!   // Give the user some help.
!   os << "The easiest way to avoid this warning is to set policy CMP0003 "
!      << "to NEW and try to build the project.  "
!      << "If any libraries in the second list below cannot be found then "
!      << "either convert them to be specified with a full path or use the "
!      << "link_directories command to add the missing linker search path.\n";
! 
!   // Name the target.
!   os << "Target \"" << this->Target->GetName() << "\" ";
! 
!   // List the items that would add paths in old behavior.
!   std::set<cmStdString> emitted;
!   os << " links to some items by full path not located in any linker search "
!      << "directory added by a link_directories command:\n";
!   for(std::vector<std::string>::const_iterator
!         i = this->OldLinkDirItems.begin();
!       i != this->OldLinkDirItems.end(); ++i)
!     {
!     if(emitted.insert(cmSystemTools::GetFilenamePath(*i)).second)
!       {
!       os << "  " << *i << "\n";
!       }
!     }
  
    // List the items that might need the old-style paths.
!   os << "This is okay but it also links to some items with no path known:\n";
    {
    // Format the list of unknown items to be as short as possible while
--- 1377,1395 ----
  
  //----------------------------------------------------------------------------
! void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
  {
!   // Tell the user what to do.
!   os << "Policy CMP0003 should be set before this line.  "
!      << "Add code such as\n"
!      << "  if(COMMAND cmake_policy)\n"
!      << "    cmake_policy(SET CMP0003 NEW)\n"
!      << "  endif(COMMAND cmake_policy)\n"
!      << "as early as possible but after the most recent call to "
!      << "cmake_minimum_required or cmake_policy(VERSION).  ";
  
    // List the items that might need the old-style paths.
!   os << "This warning appears because target \""
!      << this->Target->GetName() << "\" "
!      << "links to some libraries for which the linker must search:\n";
    {
    // Format the list of unknown items to be as short as possible while
***************
*** 1438,1442 ****
      line += sep;
      line += *i;
-     libs += *i;
      // Convert to the other separator.
      sep = ", ";
--- 1414,1417 ----
***************
*** 1448,1459 ****
    }
  
!   // Tell the user what is wrong.
!   os << "This may be okay too because the linker will search for the "
!      << "libraries in the second list.  However, "
!      << "finding them may depend on linker search paths earlier CMake "
!      << "versions added as an implementation detail for linking to the "
!      << "libraries in the first list.  "
!      << "For compatibility CMake is including the extra linker search "
!      << "paths, but policy CMP0003 should be set by the project. ";
  }
  
--- 1423,1446 ----
    }
  
!   // List the paths old behavior is adding.
!   os << "and other libraries with known full path:\n";
!   std::set<cmStdString> emitted;
!   for(std::vector<std::string>::const_iterator
!         i = this->OldLinkDirItems.begin();
!       i != this->OldLinkDirItems.end(); ++i)
!     {
!     if(emitted.insert(cmSystemTools::GetFilenamePath(*i)).second)
!       {
!       os << "  " << *i << "\n";
!       }
!     }
! 
!   // Explain.
!   os << "CMake is adding directories in the second list to the linker "
!      << "search path in case they are needed to find libraries from the "
!      << "first list (for backwards compatibility with CMake 2.4).  "
!      << "Set policy CMP0003 to OLD or NEW to enable or disable this "
!      << "behavior explicitly.  "
!      << "Run \"cmake --help-policy CMP0003\" for more information.";
  }
  

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -C 2 -d -r1.25 -r1.26
*** cmPolicies.cxx	19 Mar 2008 19:18:21 -0000	1.25
--- cmPolicies.cxx	21 Mar 2008 01:11:26 -0000	1.26
***************
*** 202,206 ****
      "  target_link_libraries(myexe /path/to/libA.so /path/to/libB.so)\n"
      "When all items on the link line have known paths CMake does not check "
!     "this policy so it has no effect.",
      2,6,0, cmPolicies::WARN);
  
--- 202,209 ----
      "  target_link_libraries(myexe /path/to/libA.so /path/to/libB.so)\n"
      "When all items on the link line have known paths CMake does not check "
!     "this policy so it has no effect.\n"
!     "Note that the warning for this policy will be issued for at most "
!     "one target.  This avoids flooding users with messages for every "
!     "target when setting the policy once will probably fix all targets.",
      2,6,0, cmPolicies::WARN);
  

Index: cmComputeLinkInformation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C 2 -d -r1.17 -r1.18
*** cmComputeLinkInformation.h	18 Mar 2008 21:32:26 -0000	1.17
--- cmComputeLinkInformation.h	21 Mar 2008 01:11:26 -0000	1.18
***************
*** 155,159 ****
    cmOrderDirectories* OrderLinkerSearchPath;
    bool FinishLinkerSearchDirectories();
!   void PrintLinkPolicyDiagnosis(std::ostream&, std::string& libs);
    std::set<cmStdString> ImplicitLinkDirs;
  
--- 155,159 ----
    cmOrderDirectories* OrderLinkerSearchPath;
    bool FinishLinkerSearchDirectories();
!   void PrintLinkPolicyDiagnosis(std::ostream&);
    std::set<cmStdString> ImplicitLinkDirs;
  



More information about the Cmake-commits mailing list