[Cmake-commits] [cmake-commits] king committed cmListFileCache.cxx 1.41 1.42 cmPolicies.cxx 1.24 1.25

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Mar 19 15:18:23 EDT 2008


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

Modified Files:
	cmListFileCache.cxx cmPolicies.cxx 
Log Message:
ENH: Improve warning about specifying a cmake version

  - Update policy CMP0000 to require use of the command
    cmake_minimum_required and not cmake_policy
    so there is only one way to avoid it.
  - Explicitly specify the line users should add.
  - Reference policy CMP0000 only at the end.
  - Fix policy CMP0000 documentation to not suggest
    use of the cmake_policy command.


Index: cmListFileCache.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmListFileCache.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -C 2 -d -r1.41 -r1.42
*** cmListFileCache.cxx	13 Mar 2008 17:48:57 -0000	1.41
--- cmListFileCache.cxx	19 Mar 2008 19:18:21 -0000	1.42
***************
*** 20,23 ****
--- 20,24 ----
  #include "cmSystemTools.h"
  #include "cmMakefile.h"
+ #include "cmVersion.h"
  
  #include <cmsys/RegularExpression.hxx>
***************
*** 122,126 ****
    if(topLevel)
    {
!     bool hasPolicy = false;
      // search for the right policy command
      for(std::vector<cmListFileFunction>::iterator i 
--- 123,127 ----
    if(topLevel)
    {
!     bool hasVersion = false;
      // search for the right policy command
      for(std::vector<cmListFileFunction>::iterator i 
***************
*** 128,165 ****
          i != this->Functions.end(); ++i)
      {
-       if (cmSystemTools::LowerCase(i->Name) == "cmake_policy" &&
-           i->Arguments.size() && 
-           cmSystemTools::LowerCase(i->Arguments[0].Value) == "version")
-       {
-         hasPolicy = true;
-         break;
-       }
        if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required")
        {
!         hasPolicy = true;
          break;
        }
      }
!     // if no policy command is found this is an error
!     if(!hasPolicy)
!     {
!       switch (mf->GetPolicyStatus(cmPolicies::CMP0000))
        {
          case cmPolicies::WARN:
!           mf->IssueMessage(cmake::AUTHOR_WARNING,
!             mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0000)
!             );
! 
            // Implicitly set the version for the user.
            mf->SetPolicyVersion("2.4");
!         case cmPolicies::OLD:
!           break; 
          default:
!           mf->IssueMessage(cmake::FATAL_ERROR,
!             mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0000)
!             );
            return false;
        }
-     }
    }
  
--- 129,166 ----
          i != this->Functions.end(); ++i)
      {
        if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required")
        {
!         hasVersion = true;
          break;
        }
      }
!     // if no version command is found this is a warning or error
!     if(!hasVersion)
        {
+       cmOStringStream msg;
+       msg << "No cmake_minimum_required command is present.  "
+           << "A line of code such as\n"
+           << "  cmake_minimum_required(VERSION "
+           << cmVersion::GetMajorVersion() << "."
+           << cmVersion::GetMinorVersion()
+           << ")\n"
+           << "should be added at the top of the file.  "
+           << "The version specified may be lower if you wish to "
+           << "support older CMake versions for this project.  "
+           << "For more information run "
+           << "\"cmake --help-policy CMP0000\".";
+       switch (mf->GetPolicyStatus(cmPolicies::CMP0000))
+         {
          case cmPolicies::WARN:
!           mf->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str());
!         case cmPolicies::OLD:
            // Implicitly set the version for the user.
            mf->SetPolicyVersion("2.4");
!           break;
          default:
!           mf->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str());
            return false;
+         }
        }
    }
  

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -C 2 -d -r1.24 -r1.25
*** cmPolicies.cxx	13 Mar 2008 21:32:13 -0000	1.24
--- cmPolicies.cxx	19 Mar 2008 19:18:21 -0000	1.25
***************
*** 88,110 ****
    this->DefinePolicy(
      CMP0000, "CMP0000",
!     "A policy version number must be specified.",
      "CMake requires that projects specify the version of CMake to which "
      "they have been written.  "
!     "This policy has been put in place to help existing projects build with "
!     "new CMake versions as it evolves.  "
!     "The easiest way to specify a policy version number is to "
!     "call the cmake_minimum_required command at the top of "
!     "your CMakeLists.txt file:\n"
      "  cmake_minimum_required(VERSION <major>.<minor>)\n"
      "where \"<major>.<minor>\" is the version of CMake you want to support "
      "(such as \"2.6\").  "
      "The command will ensure that at least the given version of CMake is "
!     "running and set the policy version.  "
!     "See documentation of cmake_minimum_required for details.  "
!     "The cmake_policy command may be used at any time to set the "
!     "policy version:\n"
!     "  cmake_policy(VERSION <major>.<minor>)\n"
!     "This is the recommended way to set the policy version except at "
!     "the very top of a project.",
      2,6,0, cmPolicies::WARN
      );
--- 88,106 ----
    this->DefinePolicy(
      CMP0000, "CMP0000",
!     "A minimum required CMake version must be specified.",
      "CMake requires that projects specify the version of CMake to which "
      "they have been written.  "
!     "This policy has been put in place so users trying to build the project "
!     "may be told when they need to update their CMake.  "
!     "Specifying a version also helps the project build with CMake versions "
!     "newer than that specified.  "
!     "Use the cmake_minimum_required command at the top of your main "
!     " CMakeLists.txt file:\n"
      "  cmake_minimum_required(VERSION <major>.<minor>)\n"
      "where \"<major>.<minor>\" is the version of CMake you want to support "
      "(such as \"2.6\").  "
      "The command will ensure that at least the given version of CMake is "
!     "running and help newer versions be compatible with the project.  "
!     "See documentation of cmake_minimum_required for details.",
      2,6,0, cmPolicies::WARN
      );
***************
*** 549,578 ****
      full << i->second->LongDescription;
      full << "\nThis policy was introduced in CMake version ";
!     full << i->second->GetVersionString() << ".  ";
!     full << "CMake version " << cmVersion::GetMajorVersion()
!          << "." << cmVersion::GetMinorVersion() << " ";
!     // add in some more text here based on status
!     switch (i->second->Status)
!     {
!       case cmPolicies::WARN:
!         full << "defaults to WARN for this policy.  "
!              << "Use the cmake_policy command to set it to OLD or NEW.";
!         break;
!       case cmPolicies::OLD:
!         full << "defaults to the OLD behavior for this policy.";
!         break;
!       case cmPolicies::NEW:
!         full << "defaults to the NEW behavior for this policy.";
!         break;
!       case cmPolicies::REQUIRED_IF_USED:
!         full << "requires the policy to be set to NEW if you use it.  "
!              << "Use the cmake_policy command to set it to NEW.";
!         break;
!       case cmPolicies::REQUIRED_ALWAYS:
!         full << "requires the policy to be set to NEW.  "
!              << "Use the cmake_policy command to set it to NEW.";
!         break;
!     }
!           
      cmDocumentationEntry e(i->second->IDString.c_str(),
                             i->second->ShortDescription.c_str(),
--- 545,578 ----
      full << i->second->LongDescription;
      full << "\nThis policy was introduced in CMake version ";
!     full << i->second->GetVersionString() << ".";
!     if(i->first != cmPolicies::CMP0000)
!       {
!       full << "  "
!            << "CMake version " << cmVersion::GetMajorVersion()
!            << "." << cmVersion::GetMinorVersion() << " ";
!       // add in some more text here based on status
!       switch (i->second->Status)
!         {
!         case cmPolicies::WARN:
!           full << "warns when the policy is not set and uses OLD behavior.  "
!                << "Use the cmake_policy command to set it to OLD or NEW "
!                << "explicitly.";
!           break;
!         case cmPolicies::OLD:
!           full << "defaults to the OLD behavior for this policy.";
!           break;
!         case cmPolicies::NEW:
!           full << "defaults to the NEW behavior for this policy.";
!           break;
!         case cmPolicies::REQUIRED_IF_USED:
!           full << "requires the policy to be set to NEW if you use it.  "
!                << "Use the cmake_policy command to set it to NEW.";
!           break;
!         case cmPolicies::REQUIRED_ALWAYS:
!           full << "requires the policy to be set to NEW.  "
!                << "Use the cmake_policy command to set it to NEW.";
!           break;
!         }
!       }
      cmDocumentationEntry e(i->second->IDString.c_str(),
                             i->second->ShortDescription.c_str(),



More information about the Cmake-commits mailing list