[Cmake-commits] [cmake-commits] king committed cmComputeLinkDepends.cxx 1.30 1.31 cmComputeLinkDepends.h 1.16 1.17 cmTarget.cxx 1.248 1.249 cmTarget.h 1.128 1.129

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jul 6 16:24:47 EDT 2009


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

Modified Files:
	cmComputeLinkDepends.cxx cmComputeLinkDepends.h cmTarget.cxx 
	cmTarget.h 
Log Message:
ENH: Move CMP0004 check into cmTarget

This moves code implementing policy CMP0004 into cmTarget::CheckCMP0004.
The implementation is slightly simpler and can be re-used outside of
cmComputeLinkDepends.


Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C 2 -d -r1.16 -r1.17
*** cmComputeLinkDepends.h	6 Apr 2009 15:10:37 -0000	1.16
--- cmComputeLinkDepends.h	6 Jul 2009 20:24:45 -0000	1.17
***************
*** 88,92 ****
    void AddLinkEntries(int depender_index,
                        std::vector<std::string> const& libs);
-   std::string CleanItemName(std::string const& item);
    cmTarget* FindTargetToLink(int depender_index, const char* name);
  
--- 88,91 ----

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.128
retrieving revision 1.129
diff -C 2 -d -r1.128 -r1.129
*** cmTarget.h	6 Jul 2009 20:24:32 -0000	1.128
--- cmTarget.h	6 Jul 2009 20:24:45 -0000	1.129
***************
*** 261,264 ****
--- 261,268 ----
    cmTargetLinkInterface const* GetLinkInterface(const char* config);
  
+   /** Strip off leading and trailing whitespace from an item named in
+       the link dependencies of this target.  */
+   std::string CheckCMP0004(std::string const& item);
+ 
    /** Get the directory in which this target will be built.  If the
        configuration name is given then the generator will add its

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -C 2 -d -r1.30 -r1.31
*** cmComputeLinkDepends.cxx	6 Apr 2009 15:10:34 -0000	1.30
--- cmComputeLinkDepends.cxx	6 Jul 2009 20:24:45 -0000	1.31
***************
*** 554,558 ****
      // Skip entries that will resolve to the target getting linked or
      // are empty.
!     std::string item = this->CleanItemName(*li);
      if(item == this->Target->GetName() || item.empty())
        {
--- 554,558 ----
      // Skip entries that will resolve to the target getting linked or
      // are empty.
!     std::string item = this->Target->CheckCMP0004(*li);
      if(item == this->Target->GetName() || item.empty())
        {
***************
*** 607,670 ****
  
  //----------------------------------------------------------------------------
- std::string cmComputeLinkDepends::CleanItemName(std::string const& item)
- {
-   // Strip whitespace off the library names because we used to do this
-   // in case variables were expanded at generate time.  We no longer
-   // do the expansion but users link to libraries like " ${VAR} ".
-   std::string lib = item;
-   std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
-   if(pos != lib.npos)
-     {
-     lib = lib.substr(pos, lib.npos);
-     }
-   pos = lib.find_last_not_of(" \t\r\n");
-   if(pos != lib.npos)
-     {
-     lib = lib.substr(0, pos+1);
-     }
-   if(lib != item)
-     {
-     switch(this->Target->GetPolicyStatusCMP0004())
-       {
-       case cmPolicies::WARN:
-         {
-         cmOStringStream w;
-         w << (this->Makefile->GetPolicies()
-               ->GetPolicyWarning(cmPolicies::CMP0004)) << "\n"
-           << "Target \"" << this->Target->GetName() << "\" links to item \""
-           << item << "\" which has leading or trailing whitespace.";
-         this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
-                                           this->Target->GetBacktrace());
-         }
-       case cmPolicies::OLD:
-         break;
-       case cmPolicies::NEW:
-         {
-         cmOStringStream e;
-         e << "Target \"" << this->Target->GetName() << "\" links to item \""
-           << item << "\" which has leading or trailing whitespace.  "
-           << "This is now an error according to policy CMP0004.";
-         this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                                           this->Target->GetBacktrace());
-         }
-         break;
-       case cmPolicies::REQUIRED_IF_USED:
-       case cmPolicies::REQUIRED_ALWAYS:
-         {
-         cmOStringStream e;
-         e << (this->Makefile->GetPolicies()
-               ->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n"
-           << "Target \"" << this->Target->GetName() << "\" links to item \""
-           << item << "\" which has leading or trailing whitespace.";
-         this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                                           this->Target->GetBacktrace());
-         }
-         break;
-       }
-     }
-   return lib;
- }
- 
- //----------------------------------------------------------------------------
  cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index,
                                                   const char* name)
--- 607,610 ----

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.248
retrieving revision 1.249
diff -C 2 -d -r1.248 -r1.249
*** cmTarget.cxx	6 Jul 2009 20:24:32 -0000	1.248
--- cmTarget.cxx	6 Jul 2009 20:24:45 -0000	1.249
***************
*** 3816,3819 ****
--- 3816,3878 ----
  
  //----------------------------------------------------------------------------
+ std::string cmTarget::CheckCMP0004(std::string const& item)
+ {
+   // Strip whitespace off the library names because we used to do this
+   // in case variables were expanded at generate time.  We no longer
+   // do the expansion but users link to libraries like " ${VAR} ".
+   std::string lib = item;
+   std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
+   if(pos != lib.npos)
+     {
+     lib = lib.substr(pos, lib.npos);
+     }
+   pos = lib.find_last_not_of(" \t\r\n");
+   if(pos != lib.npos)
+     {
+     lib = lib.substr(0, pos+1);
+     }
+   if(lib != item)
+     {
+     cmake* cm = this->Makefile->GetCMakeInstance();
+     switch(this->PolicyStatusCMP0004)
+       {
+       case cmPolicies::WARN:
+         {
+         cmOStringStream w;
+         w << (this->Makefile->GetPolicies()
+               ->GetPolicyWarning(cmPolicies::CMP0004)) << "\n"
+           << "Target \"" << this->GetName() << "\" links to item \""
+           << item << "\" which has leading or trailing whitespace.";
+         cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
+                          this->GetBacktrace());
+         }
+       case cmPolicies::OLD:
+         break;
+       case cmPolicies::NEW:
+         {
+         cmOStringStream e;
+         e << "Target \"" << this->GetName() << "\" links to item \""
+           << item << "\" which has leading or trailing whitespace.  "
+           << "This is now an error according to policy CMP0004.";
+         cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+         }
+         break;
+       case cmPolicies::REQUIRED_IF_USED:
+       case cmPolicies::REQUIRED_ALWAYS:
+         {
+         cmOStringStream e;
+         e << (this->Makefile->GetPolicies()
+               ->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n"
+           << "Target \"" << this->GetName() << "\" links to item \""
+           << item << "\" which has leading or trailing whitespace.";
+         cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+         }
+         break;
+       }
+     }
+   return lib;
+ }
+ 
+ //----------------------------------------------------------------------------
  cmComputeLinkInformation*
  cmTarget::GetLinkInformation(const char* config)



More information about the Cmake-commits mailing list