[Cmake-commits] [cmake-commits] hoffman committed cmListCommand.cxx 1.19 1.20 cmPolicies.h 1.14 1.15 cmPolicies.cxx 1.29 1.30

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Apr 21 16:57:15 EDT 2008


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

Modified Files:
	cmListCommand.cxx cmPolicies.h cmPolicies.cxx 
Log Message:
ENH: fix list command with empty elements


Index: cmListCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmListCommand.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** cmListCommand.cxx	14 Mar 2008 20:39:20 -0000	1.19
--- cmListCommand.cxx	21 Apr 2008 20:57:11 -0000	1.20
***************
*** 104,109 ****
      return false;
      }
!   // expand the variable
!   cmSystemTools::ExpandListArgument(listString, list);
    return true;
  }
--- 104,163 ----
      return false;
      }
!   // expand the variable into a list
!   cmSystemTools::ExpandListArgument(listString, list, true);
!   // check the list for empty values
!   bool hasEmpty = false;
!   for(std::vector<std::string>::iterator i = list.begin(); 
!       i != list.end(); ++i)
!     {
!     if(i->size() == 0)
!       {
!       hasEmpty = true;
!       break;
!       }
!     }
!   // if no empty elements then just return 
!   if(!hasEmpty)
!     {
!     return true;
!     }
!   // if we have empty elements we need to check policy CMP0007
!   switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0007))
!     {
!     case cmPolicies::WARN: 
!       {
!       // Default is to warn and use old behavior
!       // OLD behavior is to allow compatibility, so recall
!       // ExpandListArgument without the true which will remove
!       // empty values
!       list.clear();
!       cmSystemTools::ExpandListArgument(listString, list);
!       std::string warn = this->Makefile->GetPolicies()->
!         GetPolicyWarning(cmPolicies::CMP0007);
!       warn += " List has value = [";
!       warn += listString;
!       warn += "].";
!       this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
!                                    warn);
!       return true;
!       }
!     case cmPolicies::OLD:
!       // OLD behavior is to allow compatibility, so recall
!       // ExpandListArgument without the true which will remove
!       // empty values
!       list.clear();
!       cmSystemTools::ExpandListArgument(listString, list);
!       return true;
!     case cmPolicies::NEW:
!       return true;
!     case cmPolicies::REQUIRED_IF_USED:
!     case cmPolicies::REQUIRED_ALWAYS:
!       this->Makefile->IssueMessage(
!         cmake::FATAL_ERROR,
!         this->Makefile->GetPolicies()
!         ->GetRequiredPolicyError(cmPolicies::CMP0007)
!         );
!       return false;
!     }
    return true;
  }

Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmPolicies.h	14 Apr 2008 21:53:11 -0000	1.14
--- cmPolicies.h	21 Apr 2008 20:57:11 -0000	1.15
***************
*** 48,51 ****
--- 48,52 ----
      CMP0005, // Definition value escaping
      CMP0006, // BUNDLE install rules needed for MACOSX_BUNDLE targets
+     CMP0007, // list command handling of empty elements
  
      // 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.29
retrieving revision 1.30
diff -C 2 -d -r1.29 -r1.30
*** cmPolicies.cxx	14 Apr 2008 21:53:11 -0000	1.29
--- cmPolicies.cxx	21 Apr 2008 20:57:11 -0000	1.30
***************
*** 270,273 ****
--- 270,285 ----
      "target is installed without a BUNDLE DESTINATION.",
      2,6,0, cmPolicies::WARN);
+   
+   this->DefinePolicy(
+     CMP0007, "CMP0007",
+     "list command no longer ignores empty elements.",
+     "This policy determines whether the list command will "
+     "ignore empty elements in the list. " 
+     "CMake 2.4 and below list commands ignored all empty elements"
+     " in the list.  For example, a;b;;c would have length 3 and not 4. "
+     "The OLD behavior for this policy is to ignore empty list elements. "
+     "The NEW behavior for this policy is to correctly count empty "
+     "elements in a list. ",
+     2,6,0, cmPolicies::WARN);
  }
  



More information about the Cmake-commits mailing list