[Cmake-commits] [cmake-commits] martink committed cmCMakeMinimumRequired.cxx 1.15 1.16 cmConfigureFileCommand.cxx 1.31 1.32 cmListFileCache.cxx 1.30 1.31 cmListFileCache.h 1.18 1.19 cmMakefile.cxx 1.445 1.446 cmPolicies.cxx 1.10 1.11

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Mar 6 10:58:12 EST 2008


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

Modified Files:
	cmCMakeMinimumRequired.cxx cmConfigureFileCommand.cxx 
	cmListFileCache.cxx cmListFileCache.h cmMakefile.cxx 
	cmPolicies.cxx 
Log Message:
BUG: change the handling of CMAKE_MINIMUM_REQUIRED and BACKWARDS_COMPATIBILITY and extend the documentaiton quite a bit


Index: cmListFileCache.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmListFileCache.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -C 2 -d -r1.30 -r1.31
*** cmListFileCache.cxx	19 Nov 2007 18:42:05 -0000	1.30
--- cmListFileCache.cxx	6 Mar 2008 15:57:17 -0000	1.31
***************
*** 19,22 ****
--- 19,23 ----
  #include "cmListFileLexer.h"
  #include "cmSystemTools.h"
+ #include "cmMakefile.h"
  
  #include <cmsys/RegularExpression.hxx>
***************
*** 30,34 ****
                                    const char* filename);
  
! bool cmListFile::ParseFile(const char* filename, bool requireProjectCommand)
  {
    if(!cmSystemTools::FileExists(filename))
--- 31,37 ----
                                    const char* filename);
  
! bool cmListFile::ParseFile(const char* filename, 
!                            bool topLevel,
!                            cmMakefile *mf)
  {
    if(!cmSystemTools::FileExists(filename))
***************
*** 116,120 ****
    cmListFileLexer_Delete(lexer);
  
!   if(requireProjectCommand)
      {
      bool hasProject = false;
--- 119,176 ----
    cmListFileLexer_Delete(lexer);
  
!   // do we need a cmake_policy(VERSION call?
!   if(topLevel)
!   {
!     bool hasPolicy = false;
!     // search for the right policy command
!     for(std::vector<cmListFileFunction>::iterator i 
!           = this->Functions.begin();
!         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)
!     {
!       // add in the old CMAKE_BACKWARDS_COMPATIBILITY var for old CMake compatibility
!       if (!mf->GetCacheManager()->
!           GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
!       {
!         mf->AddCacheDefinition
!           ("CMAKE_BACKWARDS_COMPATIBILITY", "2.6",
!            "For backwards compatibility, what version of CMake commands and "
!            "syntax should this version of CMake try to support.",
!            cmCacheManager::STRING);
!       }
! 
!       switch (mf->GetPolicyStatus(cmPolicies::CMP_0000))
!       {
!         case cmPolicies::WARN:
!           cmSystemTools::Message(
!             mf->GetPolicies()->GetPolicyWarning
!               (cmPolicies::CMP_0000).c_str(),"Warning");
!         case cmPolicies::OLD:
!           break; 
!         default:
!           cmSystemTools::Error(
!             mf->GetPolicies()->GetRequiredPolicyError
!               (cmPolicies::CMP_0000).c_str());
!           return false;
!       }
!     }
!   }
! 
!   if(topLevel)
      {
      bool hasProject = false;

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -C 2 -d -r1.10 -r1.11
*** cmPolicies.cxx	5 Mar 2008 23:42:46 -0000	1.10
--- cmPolicies.cxx	6 Mar 2008 15:57:59 -0000	1.11
***************
*** 90,99 ****
      "CMake requires that projects specify what version of CMake they have "
      "been written to. The easiest way to do this is by placing a call to "
!     "cmake_policy such as the following cmake_policy(VERSION 2.6) Replace "
      "2.6 in that example with the verison of CMake you are writing to. "
      "This policy is being put in place because it aids us in detecting "
      "and maintaining backwards compatibility.",
      2,6,0, cmPolicies::WARN);
!   this->PolicyStringMap["CMP_POLICY_SPECIFICATION"] = CMP_0000;
    
    this->DefinePolicy(CMP_0001, "CMP_0001",
--- 90,100 ----
      "CMake requires that projects specify what version of CMake they have "
      "been written to. The easiest way to do this is by placing a call to "
!     "cmake_policy at the top of your CMakeLists file. For example: "
!     "cmake_policy(VERSION 2.6) Replace "
      "2.6 in that example with the verison of CMake you are writing to. "
      "This policy is being put in place because it aids us in detecting "
      "and maintaining backwards compatibility.",
      2,6,0, cmPolicies::WARN);
! //  this->PolicyStringMap["CMP_POLICY_SPECIFICATION"] = CMP_0000;
    
    this->DefinePolicy(CMP_0001, "CMP_0001",
***************
*** 103,107 ****
      ,
      2,4,0, cmPolicies::REQUIRED_IF_USED); 
!   this->PolicyStringMap["CMP_TARGET_NAMES_WITH_SLASHES"] = CMP_0001;
      
    this->DefinePolicy(CMP_0002, "CMP_0002",
--- 104,108 ----
      ,
      2,4,0, cmPolicies::REQUIRED_IF_USED); 
! //  this->PolicyStringMap["CMP_TARGET_NAMES_WITH_SLASHES"] = CMP_0001;
      
    this->DefinePolicy(CMP_0002, "CMP_0002",
***************
*** 111,115 ****
      ,
      2,6,0, cmPolicies::WARN);
!   this->PolicyStringMap["CMP_REQUIRE_UNIQUE_TARGET_NAMES"] = CMP_0002;
  
    this->DefinePolicy(CMP_0003, "CMP_0003",
--- 112,116 ----
      ,
      2,6,0, cmPolicies::WARN);
! //  this->PolicyStringMap["CMP_REQUIRE_UNIQUE_TARGET_NAMES"] = CMP_0002;
  
    this->DefinePolicy(CMP_0003, "CMP_0003",
***************
*** 121,125 ****
      ,
      2,2,0, cmPolicies::NEW);
!   this->PolicyStringMap["CMP_CONFIGURE_FILE_IMMEDIATE"] = CMP_0003;
  
    }
--- 122,126 ----
      ,
      2,2,0, cmPolicies::NEW);
! //  this->PolicyStringMap["CMP_CONFIGURE_FILE_IMMEDIATE"] = CMP_0003;
  
    }
***************
*** 183,203 ****
      return false;
      }
- 
-   // add in the old CMAKE_BACKWARDS_COMPATIBILITY var for old CMake compatibility
-   if ((majorVer == 2 && minorVer <= 4) || majorVer < 2)
-   {
-     if (!mf->GetCacheManager()->
-         GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
-     {
-       cmOStringStream v;
-       v << majorVer << "." << minorVer << "." << patchVer;
-       mf->AddCacheDefinition
-         ("CMAKE_BACKWARDS_COMPATIBILITY", v.str().c_str(),
-          "For backwards compatibility, what version of CMake commands and "
-          "syntax should this version of CMake try to support.",
-          cmCacheManager::STRING);
-     }
-   }
- 
    
    // now loop over all the policies and set them as appropriate
--- 184,187 ----
***************
*** 366,370 ****
    msg <<
      "WARNING: Policy " << pos->second->IDString << " is not set: "
!     "" << pos->second->ShortDescription << "\n"
      "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
      "policy details.  Use the cmake_policy command to set the policy "
--- 350,354 ----
    msg <<
      "WARNING: Policy " << pos->second->IDString << " is not set: "
!     "" << pos->second->ShortDescription << " "
      "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
      "policy details.  Use the cmake_policy command to set the policy "
***************
*** 429,436 ****
      std::string full;
      full += i->second->LongDescription;
      // add in some more text here based on status
!     // switch (i->second->Status)
!     // {
!       // case cmPolicies::WARN:
            
      cmDocumentationEntry e(i->second->IDString.c_str(),
--- 413,450 ----
      std::string full;
      full += i->second->LongDescription;
+     full += "\nThis policy was introduced in CMake version ";
+     full += i->second->GetVersionString();
+     full += ". The version of CMake you are running ";
      // add in some more text here based on status
!     switch (i->second->Status)
!     {
!       case cmPolicies::WARN:
!         full += "defaults to warning about this policy. You can either "
!         "suppress the warning without fixing the issue by adding a "
!         "cmake_policy(SET ";
!         full += i->second->IDString;
!         full += " OLD) command to the top of your CMakeLists file or "
!         "you can change your code to use the new behavior and add "
!         "cmake_policy(SET ";
!         full += i->second->IDString;
!         full += " NEW) to your CMakeList file. If you are fixing all "
!         "issues with a new version of CMake you can add "
!         "cmake_policy(VERSION #.#) where #.# is the verison of CMake "
!         "you are updating to. This will tell CMake that you have fixed "
!         "all issues to use the new behavior.";
!       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 new behavior for this policy."
!           "if you usee it.";
!         break;
!       case cmPolicies::REQUIRED_ALWAYS:
!         full += "requires the new behavior for this policy.";
!         break;
!     }
            
      cmDocumentationEntry e(i->second->IDString.c_str(),

Index: cmListFileCache.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmListFileCache.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C 2 -d -r1.18 -r1.19
*** cmListFileCache.h	11 May 2007 12:36:05 -0000	1.18
--- cmListFileCache.h	6 Mar 2008 15:57:39 -0000	1.19
***************
*** 27,30 ****
--- 27,32 ----
   */
  
+ class cmMakefile;
+  
  struct cmListFileArgument
  {
***************
*** 63,67 ****
      {
      }
!   bool ParseFile(const char* path, bool requireProjectCommand);
  
    long int ModifiedTime;
--- 65,71 ----
      {
      }
!   bool ParseFile(const char* path, 
!                  bool topLevel,
!                  cmMakefile *mf);
  
    long int ModifiedTime;

Index: cmConfigureFileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmConfigureFileCommand.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -C 2 -d -r1.31 -r1.32
*** cmConfigureFileCommand.cxx	5 Mar 2008 16:41:18 -0000	1.31
--- cmConfigureFileCommand.cxx	6 Mar 2008 15:57:08 -0000	1.32
***************
*** 43,59 ****
    
    // for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass,
!   // after 2.0 it only does InitialPass, this is policy CMP_0003
!   switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP_0003))
!   {
!     case cmPolicies::WARN:
!       cmSystemTools::Message(
!         this->Makefile->GetPolicies()->GetPolicyWarning
!             (cmPolicies::CMP_0003).c_str(),"Warning");
!     case cmPolicies::OLD:
!       this->Immediate = false;
!       break; 
!     default:
!       this->Immediate = true;
!   }
    
    this->AtOnly = false;
--- 43,55 ----
    
    // for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass,
!   // after 2.0 it only does InitialPass
!   this->Immediate = false;
!   const char* versionValue
!     = this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
!   if (versionValue && atof(versionValue) > 2.0)
!     {
!     this->Immediate = true;
!     }
! 
    
    this->AtOnly = false;

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.445
retrieving revision 1.446
diff -C 2 -d -r1.445 -r1.446
*** cmMakefile.cxx	5 Mar 2008 23:21:10 -0000	1.445
--- cmMakefile.cxx	6 Mar 2008 15:57:41 -0000	1.446
***************
*** 47,53 ****
    this->DefinitionStack.push_back(DefinitionMap());
  
-   // Enter a policy level for this directory.
-   this->PushPolicy();
- 
    // Setup the default include file regular expression (match everything).
    this->IncludeFileRegularExpression = "^.*$";
--- 47,50 ----
***************
*** 139,143 ****
    this->ListFileStack = mf.ListFileStack;
    this->Initialize();
-   this->PushPolicy();
  }
  
--- 136,139 ----
***************
*** 148,151 ****
--- 144,150 ----
    this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
    this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
+ 
+   // Enter a policy level for this directory.
+   this->PushPolicy();
  }
  
***************
*** 209,213 ****
      }
    this->FunctionBlockers.clear();
!   this->PolicyStack.pop_back();
  }
  
--- 208,216 ----
      }
    this->FunctionBlockers.clear();
!   if (this->PolicyStack.size() != 1)
!   {
!     cmSystemTools::Error("Internal CMake Error, Policy Stack has not been"
!       " popped properly");
!   }
  }
  
***************
*** 454,458 ****
      }
    cmListFile cacheFile;
!   if( !cacheFile.ParseFile(filenametoread, requireProjectCommand) )
      {
      // pop the listfile off the stack
--- 457,461 ----
      }
    cmListFile cacheFile;
!   if( !cacheFile.ParseFile(filenametoread, requireProjectCommand, this) )
      {
      // pop the listfile off the stack

Index: cmCMakeMinimumRequired.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCMakeMinimumRequired.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -C 2 -d -r1.15 -r1.16
*** cmCMakeMinimumRequired.cxx	4 Mar 2008 23:42:06 -0000	1.15
--- cmCMakeMinimumRequired.cxx	6 Mar 2008 15:57:03 -0000	1.16
***************
*** 109,115 ****
      }
  
-   // set the policy version as well
-   this->Makefile->SetPolicyVersion(version_string.c_str());
- 
    return true;
  }
--- 109,112 ----



More information about the Cmake-commits mailing list