[Cmake-commits] [cmake-commits] hoffman committed cmBootstrapCommands.cxx 1.27.2.1 1.27.2.2 cmCMakePolicyCommand.cxx 1.2.2.2 1.2.2.3 cmCMakePolicyCommand.h 1.4.2.2 1.4.2.3 cmCoreTryCompile.cxx 1.7.2.2 1.7.2.3 cmExportBuildFileGenerator.cxx 1.6 1.6.2.1 cmFindPackageCommand.cxx 1.36.2.7 1.36.2.8 cmFindPackageCommand.h 1.19.2.5 1.19.2.6 cmForEachCommand.cxx 1.27 1.27.2.1 cmForEachCommand.h 1.19 1.19.2.1 cmFunctionBlocker.h 1.12 1.12.2.1 cmFunctionCommand.cxx 1.6.2.1 1.6.2.2 cmFunctionCommand.h 1.3 1.3.2.1 cmGlobalVisualStudio71Generator.cxx 1.48.2.2 1.48.2.3 cmGlobalVisualStudio7Generator.cxx 1.99.2.3 1.99.2.4 cmGlobalVisualStudio7Generator.h 1.45 1.45.2.1 cmGlobalXCodeGenerator.cxx 1.186.2.9 1.186.2.10 cmIfCommand.cxx 1.84.2.4 1.84.2.5 cmIfCommand.h 1.46.2.4 1.46.2.5 cmIncludeCommand.cxx 1.21 1.21.2.1 cmIncludeCommand.h 1.17 1.17.2.1 cmLocalVisualStudio7Generator.cxx 1.217.2.14 1.217.2.15 cmMacroCommand.cxx 1.36.2.1 1.36.2.2 cmMacroCommand.h 1.16 1.16.2.1 cmMakefile.cxx 1.463.2.11 1.463.2.12 cmMakefile.h 1.230.2.7 1.230.2.8 cmPolicies.cxx 1.20.2.9 1.20.2.10 cmPolicies.h 1.10.2.7 1.10.2.8 cmTarget.cxx 1.207.2.12 1.207.2.13 cmUnsetCommand.cxx NONE 1.1.2.2 cmUnsetCommand.h NONE 1.1.2.2 cmWhileCommand.cxx 1.12.2.1 1.12.2.2 cmWhileCommand.h 1.9 1.9.2.1

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Feb 4 11:44:20 EST 2009


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

Modified Files:
      Tag: CMake-2-6
	cmBootstrapCommands.cxx cmCMakePolicyCommand.cxx 
	cmCMakePolicyCommand.h cmCoreTryCompile.cxx 
	cmExportBuildFileGenerator.cxx cmFindPackageCommand.cxx 
	cmFindPackageCommand.h cmForEachCommand.cxx cmForEachCommand.h 
	cmFunctionBlocker.h cmFunctionCommand.cxx cmFunctionCommand.h 
	cmGlobalVisualStudio71Generator.cxx 
	cmGlobalVisualStudio7Generator.cxx 
	cmGlobalVisualStudio7Generator.h cmGlobalXCodeGenerator.cxx 
	cmIfCommand.cxx cmIfCommand.h cmIncludeCommand.cxx 
	cmIncludeCommand.h cmLocalVisualStudio7Generator.cxx 
	cmMacroCommand.cxx cmMacroCommand.h cmMakefile.cxx 
	cmMakefile.h cmPolicies.cxx cmPolicies.h cmTarget.cxx 
	cmWhileCommand.cxx cmWhileCommand.h 
Added Files:
      Tag: CMake-2-6
	cmUnsetCommand.cxx cmUnsetCommand.h 
Log Message:
ENH: merge in changes to 2.6 RC 10


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.217.2.14
retrieving revision 1.217.2.15
diff -C 2 -d -r1.217.2.14 -r1.217.2.15
*** cmLocalVisualStudio7Generator.cxx	13 Jan 2009 18:03:53 -0000	1.217.2.14
--- cmLocalVisualStudio7Generator.cxx	4 Feb 2009 16:44:17 -0000	1.217.2.15
***************
*** 1303,1311 ****
        lang = sourceLang;
        }
-     // If lang is set, the compiler will generate code automatically.
      // If HEADER_FILE_ONLY is set, we must suppress this generation in
      // the project file
      fc.ExcludedFromBuild =
!       (lang && sf.GetPropertyAsBool("HEADER_FILE_ONLY"));
      if(fc.ExcludedFromBuild)
        {
--- 1303,1310 ----
        lang = sourceLang;
        }
      // If HEADER_FILE_ONLY is set, we must suppress this generation in
      // the project file
      fc.ExcludedFromBuild =
!       (sf.GetPropertyAsBool("HEADER_FILE_ONLY"));
      if(fc.ExcludedFromBuild)
        {

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.20.2.9
retrieving revision 1.20.2.10
diff -C 2 -d -r1.20.2.9 -r1.20.2.10
*** cmPolicies.cxx	24 Oct 2008 15:18:54 -0000	1.20.2.9
--- cmPolicies.cxx	4 Feb 2009 16:44:17 -0000	1.20.2.10
***************
*** 336,339 ****
--- 336,359 ----
      "The NEW behavior for this policy is to report an error.",
      2,6,3, cmPolicies::WARN);
+ 
+   this->DefinePolicy(
+     CMP0011, "CMP0011",
+     "Included scripts do automatic cmake_policy PUSH and POP.",
+     "In CMake 2.6.2 and below, CMake Policy settings in scripts loaded by "
+     "the include() and find_package() commands would affect the includer.  "
+     "Explicit invocations of cmake_policy(PUSH) and cmake_policy(POP) were "
+     "required to isolate policy changes and protect the includer.  "
+     "While some scripts intend to affect the policies of their includer, "
+     "most do not.  "
+     "In CMake 2.6.3 and above, include() and find_package() by default PUSH "
+     "and POP an entry on the policy stack around an included script, "
+     "but provide a NO_POLICY_SCOPE option to disable it.  "
+     "This policy determines whether or not to imply NO_POLICY_SCOPE for "
+     "compatibility.  "
+     "The OLD behavior for this policy is to imply NO_POLICY_SCOPE for "
+     "include() and find_package() commands.  "
+     "The NEW behavior for this policy is to allow the commands to do their "
+     "default cmake_policy PUSH and POP.",
+     2,6,3, cmPolicies::WARN);
  }
  

Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.84.2.4
retrieving revision 1.84.2.5
diff -C 2 -d -r1.84.2.4 -r1.84.2.5
*** cmIfCommand.cxx	24 Oct 2008 15:18:48 -0000	1.84.2.4
--- cmIfCommand.cxx	4 Feb 2009 16:44:17 -0000	1.84.2.5
***************
*** 28,38 ****
                    cmExecutionStatus &inStatus)
  {
-   // Prevent recusion and don't let this blocker block its own
-   // commands.
-   if (this->Executing)
-     {
-     return false;
-     }
- 
    // we start by recording all the functions
    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
--- 28,31 ----
***************
*** 46,51 ****
      if (!this->ScopeDepth) 
        {
        // execute the functions for the true parts of the if statement
-       this->Executing = true;
        cmExecutionStatus status;
        int scopeDepth = 0;
--- 39,48 ----
      if (!this->ScopeDepth) 
        {
+       // Remove the function blocker for this scope or bail.
+       cmsys::auto_ptr<cmFunctionBlocker>
+         fb(mf.RemoveFunctionBlocker(this, lff));
+       if(!fb.get()) { return false; }
+ 
        // execute the functions for the true parts of the if statement
        cmExecutionStatus status;
        int scopeDepth = 0;
***************
*** 77,80 ****
--- 74,81 ----
            else
              {
+             // Place this call on the call stack.
+             cmMakefileCall stack_manager(&mf, this->Functions[c], status);
+             static_cast<void>(stack_manager);
+ 
              std::string errorString;
              
***************
*** 99,104 ****
                err += errorString;
                err += ").";
!               cmSystemTools::Error(err.c_str());
!               return false;
                }
          
--- 100,106 ----
                err += errorString;
                err += ").";
!               mf.IssueMessage(cmake::FATAL_ERROR, err);
!               cmSystemTools::SetFatalErrorOccured();
!               return true;
                }
          
***************
*** 119,123 ****
              {
              inStatus.SetReturnInvoked(true);
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 121,124 ----
***************
*** 125,134 ****
              {
              inStatus.SetBreakInvoked(true);
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
            }
          }
-       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 126,133 ----
***************
*** 161,182 ****
  
  //=========================================================================
- void cmIfFunctionBlocker::ScopeEnded(cmMakefile &mf)
- {
-   std::string errmsg = "The end of a CMakeLists file was reached with an "
-     "IF statement that was not closed properly.\nWithin the directory: ";
-   errmsg += mf.GetCurrentDirectory();
-   errmsg += "\nThe arguments are: ";
-   for(std::vector<cmListFileArgument>::const_iterator j = this->Args.begin();
-       j != this->Args.end(); ++j)
-     {   
-     errmsg += (j->Quoted?"\"":"");
-     errmsg += j->Value;
-     errmsg += (j->Quoted?"\"":"");
-     errmsg += " ";
-     }
-   cmSystemTools::Message(errmsg.c_str(), "Warning");
- }
- 
- //=========================================================================
  bool cmIfCommand
  ::InvokeInitialPass(const std::vector<cmListFileArgument>& args, 
--- 160,163 ----
***************
*** 205,208 ****
--- 186,190 ----
      err += ").";
      this->SetError(err.c_str());
+     cmSystemTools::SetFatalErrorOccured();
      return false;
      }

Index: cmIfCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.h,v
retrieving revision 1.46.2.4
retrieving revision 1.46.2.5
diff -C 2 -d -r1.46.2.4 -r1.46.2.5
*** cmIfCommand.h	24 Oct 2008 15:18:48 -0000	1.46.2.4
--- cmIfCommand.h	4 Feb 2009 16:44:17 -0000	1.46.2.5
***************
*** 30,34 ****
  public:
    cmIfFunctionBlocker() {
!     this->HasRun = false; this->ScopeDepth = 0; this->Executing = false;}
    virtual ~cmIfFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
--- 30,34 ----
  public:
    cmIfFunctionBlocker() {
!     this->HasRun = false; this->ScopeDepth = 0; }
    virtual ~cmIfFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
***************
*** 37,41 ****
    virtual bool ShouldRemove(const cmListFileFunction& lff,
                              cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<cmListFileArgument> Args;
--- 37,40 ----
***************
*** 44,48 ****
    bool HasRun;
    unsigned int ScopeDepth;
-   bool Executing;
  };
  
--- 43,46 ----

Index: cmWhileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.h,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C 2 -d -r1.9 -r1.9.2.1
*** cmWhileCommand.h	23 Jan 2008 15:27:59 -0000	1.9
--- cmWhileCommand.h	4 Feb 2009 16:44:18 -0000	1.9.2.1
***************
*** 30,34 ****
  {
  public:
!   cmWhileFunctionBlocker() {Executing = false; Depth=0;}
    virtual ~cmWhileFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
--- 30,34 ----
  {
  public:
!   cmWhileFunctionBlocker() {this->Depth=0;}
    virtual ~cmWhileFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
***************
*** 36,44 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<cmListFileArgument> Args;
    std::vector<cmListFileFunction> Functions;
-   bool Executing;
  private:
    int Depth;
--- 36,42 ----

Index: cmGlobalVisualStudio71Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio71Generator.cxx,v
retrieving revision 1.48.2.2
retrieving revision 1.48.2.3
diff -C 2 -d -r1.48.2.2 -r1.48.2.3
*** cmGlobalVisualStudio71Generator.cxx	24 Oct 2008 15:18:46 -0000	1.48.2.2
--- cmGlobalVisualStudio71Generator.cxx	4 Feb 2009 16:44:17 -0000	1.48.2.3
***************
*** 116,120 ****
                        originalTargets,
                        root, generators);
!   this->WriteTargetsToSolution(fout, root, projectTargets, originalTargets);
    // Write out the configurations information for the solution
    fout << "Global\n";
--- 116,122 ----
                        originalTargets,
                        root, generators);
!   OrderedTargetDependSet orderedProjectTargets(projectTargets);
!   this->WriteTargetsToSolution(fout, root, orderedProjectTargets,
!                                originalTargets);
    // Write out the configurations information for the solution
    fout << "Global\n";
***************
*** 124,128 ****
         << ") = postSolution\n";
    // Write out the configurations for all the targets in the project
!   this->WriteTargetConfigurations(fout, root, projectTargets);
    fout << "\tEndGlobalSection\n";
    // Write the footer for the SLN file
--- 126,130 ----
         << ") = postSolution\n";
    // Write out the configurations for all the targets in the project
!   this->WriteTargetConfigurations(fout, root, orderedProjectTargets);
    fout << "\tEndGlobalSection\n";
    // Write the footer for the SLN file

Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.19.2.5
retrieving revision 1.19.2.6
diff -C 2 -d -r1.19.2.5 -r1.19.2.6
*** cmFindPackageCommand.h	13 Jan 2009 18:03:52 -0000	1.19.2.5
--- cmFindPackageCommand.h	4 Feb 2009 16:44:17 -0000	1.19.2.6
***************
*** 83,87 ****
    bool FindFrameworkConfig();
    bool FindAppBundleConfig();
!   bool ReadListFile(const char* f);
    void StoreVersionFound();
  
--- 83,88 ----
    bool FindFrameworkConfig();
    bool FindAppBundleConfig();
!   enum PolicyScopeRule { NoPolicyScope, DoPolicyScope };
!   bool ReadListFile(const char* f, PolicyScopeRule psr);
    void StoreVersionFound();
  
***************
*** 133,136 ****
--- 134,138 ----
    bool DebugMode;
    bool UseLib64Paths;
+   bool PolicyScope;
    std::vector<std::string> Names;
    std::vector<std::string> Configs;

Index: cmFunctionCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionCommand.cxx,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -C 2 -d -r1.6.2.1 -r1.6.2.2
*** cmFunctionCommand.cxx	15 Jan 2009 14:17:20 -0000	1.6.2.1
--- cmFunctionCommand.cxx	4 Feb 2009 16:44:17 -0000	1.6.2.2
***************
*** 37,40 ****
--- 37,41 ----
      newC->Args = this->Args;
      newC->Functions = this->Functions;
+     newC->Policies = this->Policies;
      return newC;
    }
***************
*** 82,85 ****
--- 83,87 ----
    std::vector<std::string> Args;
    std::vector<cmListFileFunction> Functions;
+   cmPolicies::PolicyMap Policies;
  };
  
***************
*** 105,111 ****
--- 107,118 ----
  
    // we push a scope on the makefile
+   cmMakefile::LexicalPushPop lexScope(this->Makefile);
    cmMakefile::ScopePushPop varScope(this->Makefile);
    static_cast<void>(varScope);
  
+   // Push a weak policy scope which restores the policies recorded at
+   // function creation.
+   cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
+ 
    // set the value of argc
    cmOStringStream strStream;
***************
*** 164,167 ****
--- 171,176 ----
        // The error message should have already included the call stack
        // so we do not need to report an error here.
+       lexScope.Quiet();
+       polScope.Quiet();
        inStatus.SetNestedError(true);
        return false;
***************
*** 205,208 ****
--- 214,218 ----
        f->Args = this->Args;
        f->Functions = this->Functions;
+       mf.RecordPolicies(f->Policies);
        
        // Set the FilePath on the arguments to match the function since it is
***************
*** 223,227 ****
  
        // remove the function blocker now that the function is defined
!       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 233,237 ----
  
        // remove the function blocker now that the function is defined
!       mf.RemoveFunctionBlocker(this, lff);
        return true;
        }
***************
*** 259,273 ****
  }
  
- void cmFunctionFunctionBlocker::
- ScopeEnded(cmMakefile &mf)
- {
-   // functions should end with an EndFunction
-   cmSystemTools::Error(
-     "The end of a CMakeLists file was reached with a FUNCTION statement that "
-     "was not closed properly. Within the directory: ",
-     mf.GetCurrentDirectory(), " with function ",
-     this->Args[0].c_str());
- }
- 
  bool cmFunctionCommand
  ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
--- 269,272 ----

Index: cmBootstrapCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmBootstrapCommands.cxx,v
retrieving revision 1.27.2.1
retrieving revision 1.27.2.2
diff -C 2 -d -r1.27.2.1 -r1.27.2.2
*** cmBootstrapCommands.cxx	13 Jul 2008 21:55:23 -0000	1.27.2.1
--- cmBootstrapCommands.cxx	4 Feb 2009 16:44:16 -0000	1.27.2.2
***************
*** 94,97 ****
--- 94,98 ----
  #include "cmTryCompileCommand.cxx"
  #include "cmTryRunCommand.cxx"
+ #include "cmUnsetCommand.cxx"
  
  void GetBootstrapCommands(std::list<cmCommand*>& commands)
***************
*** 164,166 ****
--- 165,168 ----
    commands.push_back(new cmTryCompileCommand);
    commands.push_back(new cmTryRunCommand);
+   commands.push_back(new cmUnsetCommand);
  }

Index: cmCMakePolicyCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCMakePolicyCommand.h,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -C 2 -d -r1.4.2.2 -r1.4.2.3
*** cmCMakePolicyCommand.h	3 Sep 2008 13:43:17 -0000	1.4.2.2
--- cmCMakePolicyCommand.h	4 Feb 2009 16:44:16 -0000	1.4.2.3
***************
*** 114,127 ****
        "policy is set, and empty otherwise."
        "\n"
        "  cmake_policy(PUSH)\n"
        "  cmake_policy(POP)\n"
!       "Push and pop the current policy setting state on a stack.  "
!       "Each PUSH must have a matching POP.  "
!       "This is useful when mixing multiple projects, subprojects, and "
!       "files included from external projects that may each have been "
!       "written for a different version of CMake.  "
!       "Each subdirectory entered by the project automatically pushes "
!       "a new level on the stack to isolate the subdirectories from "
!       "their parents.";
      }
    
--- 114,137 ----
        "policy is set, and empty otherwise."
        "\n"
+       "CMake keeps policy settings on a stack, so changes made by the "
+       "cmake_policy command affect only the top of the stack.  "
+       "A new entry on the policy stack is managed automatically for each "
+       "subdirectory to protect its parents and siblings.  "
+       "CMake also manages a new entry for scripts loaded by include() and "
+       "find_package() commands except when invoked with the NO_POLICY_SCOPE "
+       "option (see also policy CMP0011).  "
+       "The cmake_policy command provides an interface to manage custom "
+       "entries on the policy stack:\n"
        "  cmake_policy(PUSH)\n"
        "  cmake_policy(POP)\n"
!       "Each PUSH must have a matching POP to erase any changes.  "
!       "This is useful to make temporary changes to policy settings."
!       "\n"
!       "Functions and macros record policy settings when they are created "
!       "and use the pre-record policies when they are invoked.  "
!       "If the function or macro implementation sets policies, the changes "
!       "automatically propagate up through callers until they reach the "
!       "closest nested policy stack entry."
!       ;
      }
    

Index: cmExportBuildFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportBuildFileGenerator.cxx,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C 2 -d -r1.6 -r1.6.2.1
*** cmExportBuildFileGenerator.cxx	6 Feb 2008 19:20:35 -0000	1.6
--- cmExportBuildFileGenerator.cxx	4 Feb 2009 16:44:17 -0000	1.6.2.1
***************
*** 107,119 ****
    prop += suffix;
    std::string value;
!   if(target->IsFrameworkOnApple())
!     {
!     value = target->GetFullPath(config, false);
!     }
!   else if(target->IsAppBundleOnApple())
      {
      value = target->GetFullPath(config, false);
-     value += ".app/Contents/MacOS/";
-     value += target->GetFullName(config, false);
      }
    else
--- 107,113 ----
    prop += suffix;
    std::string value;
!   if(target->IsFrameworkOnApple() || target->IsAppBundleOnApple())
      {
      value = target->GetFullPath(config, false);
      }
    else

Index: cmForEachCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmForEachCommand.h,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -C 2 -d -r1.19 -r1.19.2.1
*** cmForEachCommand.h	23 Jan 2008 15:27:59 -0000	1.19
--- cmForEachCommand.h	4 Feb 2009 16:44:17 -0000	1.19.2.1
***************
*** 30,34 ****
  {
  public:
!   cmForEachFunctionBlocker() {this->Executing = false; Depth = 0;}
    virtual ~cmForEachFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
--- 30,34 ----
  {
  public:
!   cmForEachFunctionBlocker() {this->Depth = 0;}
    virtual ~cmForEachFunctionBlocker() {}
    virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
***************
*** 36,44 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<std::string> Args;
    std::vector<cmListFileFunction> Functions;
-   bool Executing;
  private:
    int Depth;
--- 36,42 ----

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.207.2.12
retrieving revision 1.207.2.13
diff -C 2 -d -r1.207.2.12 -r1.207.2.13
*** cmTarget.cxx	13 Jan 2009 18:03:53 -0000	1.207.2.12
--- cmTarget.cxx	4 Feb 2009 16:44:17 -0000	1.207.2.13
***************
*** 1933,1936 ****
--- 1933,1941 ----
      this->Location += "/";
      }
+   if(this->IsAppBundleOnApple())
+     {
+     this->Location += this->GetFullName(config, false);
+     this->Location += ".app/Contents/MacOS/";
+     }
     if(this->IsFrameworkOnApple())
      {
***************
*** 2447,2450 ****
--- 2452,2460 ----
    fpath += "/";
  
+   if(this->IsAppBundleOnApple())
+     {
+     fpath += this->GetFullName(config, false);
+     fpath += ".app/Contents/MacOS/";
+     }
    if(this->IsFrameworkOnApple())
      {

Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.186.2.9
retrieving revision 1.186.2.10
diff -C 2 -d -r1.186.2.9 -r1.186.2.10
*** cmGlobalXCodeGenerator.cxx	24 Oct 2008 15:18:48 -0000	1.186.2.9
--- cmGlobalXCodeGenerator.cxx	4 Feb 2009 16:44:17 -0000	1.186.2.10
***************
*** 2608,2616 ****
          {
          std::string tfull = t->GetFullPath(configName);
-         if(t->IsAppBundleOnApple())
-           {
-           tfull += ".app/Contents/MacOS/";
-           tfull += t->GetFullName(configName);
-           }
          makefileStream << "\\\n\t" <<
            this->ConvertToRelativeForMake(tfull.c_str());
--- 2608,2611 ----
***************
*** 2670,2678 ****
          // Create a rule for this target.
          std::string tfull = t->GetFullPath(configName);
-         if(t->IsAppBundleOnApple())
-           {
-           tfull += ".app/Contents/MacOS/";
-           tfull += t->GetFullName(configName);
-           }
          makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) 
                         << ":";
--- 2665,2668 ----

Index: cmWhileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmWhileCommand.cxx,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -C 2 -d -r1.12.2.1 -r1.12.2.2
*** cmWhileCommand.cxx	24 Oct 2008 15:18:54 -0000	1.12.2.1
--- cmWhileCommand.cxx	4 Feb 2009 16:44:17 -0000	1.12.2.2
***************
*** 22,32 ****
                    cmExecutionStatus &inStatus)
  {
-   // Prevent recusion and don't let this blocker block its own
-   // commands.
-   if (this->Executing)
-     {
-     return false;
-     }
-   
    // at end of for each execute recorded commands
    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"while"))
--- 22,25 ----
***************
*** 40,43 ****
--- 33,41 ----
      if (!this->Depth) 
        {
+       // Remove the function blocker for this scope or bail.
+       cmsys::auto_ptr<cmFunctionBlocker>
+         fb(mf.RemoveFunctionBlocker(this, lff));
+       if(!fb.get()) { return false; }
+ 
        std::string errorString;
      
***************
*** 47,51 ****
          cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
  
-       this->Executing = true;
        while (isTrue)
          {      
--- 45,48 ----
***************
*** 58,67 ****
              {
              inStatus.SetReturnInvoked(true);
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
            if (status.GetBreakInvoked())
              {
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 55,62 ----
***************
*** 72,76 ****
            cmIfCommand::IsTrue(expandedArguments,errorString,&mf);
          }
-       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 67,70 ----
***************
*** 105,117 ****
  }
  
- void cmWhileFunctionBlocker::
- ScopeEnded(cmMakefile &mf) 
- {
-   cmSystemTools::Error(
-     "The end of a CMakeLists file was reached with a WHILE statement that "
-     "was not closed properly. Within the directory: ", 
-     mf.GetCurrentDirectory());
- }
- 
  bool cmWhileCommand
  ::InvokeInitialPass(const std::vector<cmListFileArgument>& args, 
--- 99,102 ----

Index: cmForEachCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmForEachCommand.cxx,v
retrieving revision 1.27
retrieving revision 1.27.2.1
diff -C 2 -d -r1.27 -r1.27.2.1
*** cmForEachCommand.cxx	29 Feb 2008 17:18:11 -0000	1.27
--- cmForEachCommand.cxx	4 Feb 2009 16:44:17 -0000	1.27.2.1
***************
*** 21,31 ****
                    cmExecutionStatus &inStatus)
  {
-   // Prevent recusion and don't let this blocker block its own
-   // commands.
-   if (this->Executing)
-     {
-     return false;
-     }
- 
    if (!cmSystemTools::Strucmp(lff.Name.c_str(),"foreach"))
      {
--- 21,24 ----
***************
*** 38,41 ****
--- 31,39 ----
      if (!this->Depth) 
        {
+       // Remove the function blocker for this scope or bail.
+       cmsys::auto_ptr<cmFunctionBlocker>
+         fb(mf.RemoveFunctionBlocker(this, lff));
+       if(!fb.get()) { return false; }
+ 
        // at end of for each execute recorded commands
        // store the old value
***************
*** 45,49 ****
          oldDef = mf.GetDefinition(this->Args[0].c_str());
          }
-       this->Executing = true;
        std::vector<std::string>::const_iterator j = this->Args.begin();
        ++j;
--- 43,46 ----
***************
*** 66,70 ****
              // restore the variable to its prior value
              mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 63,66 ----
***************
*** 73,77 ****
              // restore the variable to its prior value
              mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
-             mf.RemoveFunctionBlocker(lff);
              return true;
              }
--- 69,72 ----
***************
*** 80,84 ****
        // restore the variable to its prior value
        mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
-       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 75,78 ----
***************
*** 115,127 ****
  }
  
- void cmForEachFunctionBlocker::
- ScopeEnded(cmMakefile &mf) 
- {
-   cmSystemTools::Error("The end of a CMakeLists file was reached with a "
-                        "FOREACH statement that was not closed properly. "
-                        "Within the directory: ", 
-                        mf.GetCurrentDirectory());
- }
- 
  bool cmForEachCommand
  ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
--- 109,112 ----

Index: cmIncludeCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIncludeCommand.cxx,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -C 2 -d -r1.21 -r1.21.2.1
*** cmIncludeCommand.cxx	8 Mar 2008 14:27:44 -0000	1.21
--- cmIncludeCommand.cxx	4 Feb 2009 16:44:17 -0000	1.21.2.1
***************
*** 29,32 ****
--- 29,33 ----
      }
    bool optional = false;
+   bool noPolicyScope = false;
    std::string fname = args[0];
    std::string resultVarName;
***************
*** 61,64 ****
--- 62,69 ----
          }
        }
+     else if(args[i] == "NO_POLICY_SCOPE")
+       {
+       noPolicyScope = true;
+       }
        else if(i > 1)  // compat.: in previous cmake versions the second 
                        // parameter was ignore if it wasn't "OPTIONAL"
***************
*** 85,89 ****
    bool readit = 
      this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), 
!                                   fname.c_str(), &fullFilePath );
    
    // add the location of the included file if a result variable was given
--- 90,95 ----
    bool readit = 
      this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), 
!                                   fname.c_str(), &fullFilePath,
!                                   noPolicyScope);
    
    // add the location of the included file if a result variable was given

Index: cmGlobalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.h,v
retrieving revision 1.45
retrieving revision 1.45.2.1
diff -C 2 -d -r1.45 -r1.45.2.1
*** cmGlobalVisualStudio7Generator.h	31 Jan 2008 21:38:45 -0000	1.45
--- cmGlobalVisualStudio7Generator.h	4 Feb 2009 16:44:17 -0000	1.45.2.1
***************
*** 98,101 ****
--- 98,106 ----
    virtual const char* GetCMakeCFGInitDirectory()  { return "$(OutDir)"; }
  
+   struct TargetCompare
+   {
+     bool operator()(cmTarget const* l, cmTarget const* r);
+   };
+ 
  protected:
    static cmVS7FlagTable const* GetExtraFlagTableVS7();
***************
*** 115,130 ****
    virtual void AddPlatformDefinitions(cmMakefile* mf);
  
    virtual void WriteTargetsToSolution(
      std::ostream& fout,
      cmLocalGenerator* root,
!     cmGlobalGenerator::TargetDependSet& projectTargets,
      cmGlobalGenerator::TargetDependSet& originalTargets);
    virtual void WriteTargetDepends(
      std::ostream& fout,
!     cmGlobalGenerator::TargetDependSet& projectTargets);
    virtual void WriteTargetConfigurations(
      std::ostream& fout,
      cmLocalGenerator* root,
!     cmGlobalGenerator::TargetDependSet& projectTargets);
    
    void AddAllBuildDepends(cmLocalGenerator* root,
--- 120,141 ----
    virtual void AddPlatformDefinitions(cmMakefile* mf);
  
+   class OrderedTargetDependSet: public std::multiset<cmTarget*, TargetCompare>
+   {
+   public:
+     OrderedTargetDependSet(cmGlobalGenerator::TargetDependSet const&);
+   };
+ 
    virtual void WriteTargetsToSolution(
      std::ostream& fout,
      cmLocalGenerator* root,
!     OrderedTargetDependSet const& projectTargets,
      cmGlobalGenerator::TargetDependSet& originalTargets);
    virtual void WriteTargetDepends(
      std::ostream& fout,
!     OrderedTargetDependSet const& projectTargets);
    virtual void WriteTargetConfigurations(
      std::ostream& fout,
      cmLocalGenerator* root,
!     OrderedTargetDependSet const& projectTargets);
    
    void AddAllBuildDepends(cmLocalGenerator* root,

Index: cmFunctionBlocker.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionBlocker.h,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C 2 -d -r1.12 -r1.12.2.1
*** cmFunctionBlocker.h	23 Jan 2008 15:27:59 -0000	1.12
--- cmFunctionBlocker.h	4 Feb 2009 16:44:17 -0000	1.12.2.1
***************
*** 20,23 ****
--- 20,24 ----
  #include "cmStandardIncludes.h"
  #include "cmExecutionStatus.h"
+ #include "cmListFileCache.h"
  class cmMakefile;
  
***************
*** 44,55 ****
                              cmMakefile&) {return false;}
  
-   /**
-    * When the end of a CMakeList file is reached this method is called.  It
-    * is not called on the end of an INCLUDE cmake file, just at the end of a
-    * regular CMakeList file 
-    */
-   virtual void ScopeEnded(cmMakefile&) {}
- 
    virtual ~cmFunctionBlocker() {}
  };
  
--- 45,57 ----
                              cmMakefile&) {return false;}
  
    virtual ~cmFunctionBlocker() {}
+ 
+   /** Set/Get the context in which this blocker is created.  */
+   void SetStartingContext(cmListFileContext const& lfc)
+     { this->StartingContext = lfc; }
+   cmListFileContext const& GetStartingContext()
+     { return this->StartingContext; }
+ private:
+   cmListFileContext StartingContext;
  };
  

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.463.2.11
retrieving revision 1.463.2.12
diff -C 2 -d -r1.463.2.11 -r1.463.2.12
*** cmMakefile.cxx	15 Jan 2009 14:17:20 -0000	1.463.2.11
--- cmMakefile.cxx	4 Feb 2009 16:44:17 -0000	1.463.2.12
***************
*** 150,153 ****
--- 150,156 ----
    this->PushPolicy();
  
+   // Protect the directory-level policies.
+   this->PushPolicyBarrier();
+ 
    // By default the check is not done.  It is enabled by
    // cmListFileCache in the top level if necessary.
***************
*** 206,210 ****
        }
      }
!   std::list<cmFunctionBlocker *>::iterator pos;
    for (pos = this->FunctionBlockers.begin();
         pos != this->FunctionBlockers.end(); ++pos)
--- 209,213 ----
        }
      }
!   std::vector<cmFunctionBlocker*>::iterator pos;
    for (pos = this->FunctionBlockers.begin();
         pos != this->FunctionBlockers.end(); ++pos)
***************
*** 349,372 ****
  
  //----------------------------------------------------------------------------
- // Helper class to make sure the call stack is valid.
- class cmMakefileCall
- {
- public:
-   cmMakefileCall(cmMakefile* mf,
-                  cmListFileContext const& lfc,
-                  cmExecutionStatus& status): Makefile(mf)
-     {
-     cmMakefile::CallStackEntry entry = {&lfc, &status};
-     this->Makefile->CallStack.push_back(entry);
-     }
-   ~cmMakefileCall()
-     {
-     this->Makefile->CallStack.pop_back();
-     }
- private:
-   cmMakefile* Makefile;
- };
- 
- //----------------------------------------------------------------------------
  bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
                                  cmExecutionStatus &status)
--- 352,355 ----
***************
*** 461,469 ****
  }
  
  // Parse the given CMakeLists.txt file executing all commands
  //
  bool cmMakefile::ReadListFile(const char* filename_in,
                                const char *external_in,
!                               std::string* fullPath)
  {
    std::string currentParentFile
--- 444,577 ----
  }
  
+ //----------------------------------------------------------------------------
+ class cmMakefile::IncludeScope
+ {
+ public:
+   IncludeScope(cmMakefile* mf, const char* fname, bool noPolicyScope);
+   ~IncludeScope();
+   void Quiet() { this->ReportError = false; }
+ private:
+   cmMakefile* Makefile;
+   const char* File;
+   bool NoPolicyScope;
+   bool CheckCMP0011;
+   bool ReportError;
+   void EnforceCMP0011();
+ };
+ 
+ //----------------------------------------------------------------------------
+ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, const char* fname,
+                                        bool noPolicyScope):
+   Makefile(mf), File(fname), NoPolicyScope(noPolicyScope),
+   CheckCMP0011(false), ReportError(true)
+ {
+   if(!this->NoPolicyScope)
+     {
+     // Check CMP0011 to determine the policy scope type.
+     switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011))
+       {
+       case cmPolicies::WARN:
+         // We need to push a scope to detect whether the script sets
+         // any policies that would affect the includer and therefore
+         // requires a warning.  We use a weak scope to simulate OLD
+         // behavior by allowing policy changes to affect the includer.
+         this->Makefile->PushPolicy(true);
+         this->CheckCMP0011 = true;
+         break;
+       case cmPolicies::OLD:
+         // OLD behavior is to not push a scope at all.
+         this->NoPolicyScope = true;
+         break;
+       case cmPolicies::REQUIRED_IF_USED:
+       case cmPolicies::REQUIRED_ALWAYS:
+         // We should never make this policy required, but we handle it
+         // here just in case.
+         this->CheckCMP0011 = true;
+       case cmPolicies::NEW:
+         // NEW behavior is to push a (strong) scope.
+         this->Makefile->PushPolicy();
+         break;
+       }
+     }
+ 
+   // The included file cannot pop our policy scope.
+   this->Makefile->PushPolicyBarrier();
+ }
+ 
+ //----------------------------------------------------------------------------
+ cmMakefile::IncludeScope::~IncludeScope()
+ {
+   // Enforce matching policy scopes inside the included file.
+   this->Makefile->PopPolicyBarrier(this->ReportError);
+ 
+   if(!this->NoPolicyScope)
+     {
+     // If we need to enforce policy CMP0011 then the top entry is the
+     // one we pushed above.  If the entry is empty, then the included
+     // script did not set any policies that might affect the includer so
+     // we do not need to enforce the policy.
+     if(this->CheckCMP0011 && this->Makefile->PolicyStack.back().empty())
+       {
+       this->CheckCMP0011 = false;
+       }
+ 
+     // Pop the scope we pushed for the script.
+     this->Makefile->PopPolicy();
+ 
+     // We enforce the policy after the script's policy stack entry has
+     // been removed.
+     if(this->CheckCMP0011)
+       {
+       this->EnforceCMP0011();
+       }
+     }
+ }
+ 
+ //----------------------------------------------------------------------------
+ void cmMakefile::IncludeScope::EnforceCMP0011()
+ {
+   // We check the setting of this policy again because the included
+   // script might actually set this policy for its includer.
+   cmPolicies* policies = this->Makefile->GetPolicies();
+   switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011))
+     {
+     case cmPolicies::WARN:
+       // Warn because the user did not set this policy.
+       {
+       cmOStringStream w;
+       w << policies->GetPolicyWarning(cmPolicies::CMP0011) << "\n"
+         << "The included script\n  " << this->File << "\n"
+         << "affects policy settings.  "
+         << "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
+         << "so the effects are applied to the including context.";
+       this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+       }
+       break;
+     case cmPolicies::REQUIRED_IF_USED:
+     case cmPolicies::REQUIRED_ALWAYS:
+       {
+       cmOStringStream e;
+       e << policies->GetRequiredPolicyError(cmPolicies::CMP0011) << "\n"
+         << "The included script\n  " << this->File << "\n"
+         << "affects policy settings, so it requires this policy to be set.";
+       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+       }
+       break;
+     case cmPolicies::OLD:
+     case cmPolicies::NEW:
+       // The script set this policy.  We assume the purpose of the
+       // script is to initialize policies for its includer, and since
+       // the policy is now set for later scripts, we do not warn.
+       break;
+     }
+ }
+ 
+ //----------------------------------------------------------------------------
  // Parse the given CMakeLists.txt file executing all commands
  //
  bool cmMakefile::ReadListFile(const char* filename_in,
                                const char *external_in,
!                               std::string* fullPath,
!                               bool noPolicyScope)
  {
    std::string currentParentFile
***************
*** 473,480 ****
    this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename_in);
  
-   // used to watch for blockers going out of scope
-   // e.g. mismatched IF statement
-   std::set<cmFunctionBlocker *> originalBlockers;
- 
    const char* external = 0;
    std::string external_abs;
--- 581,584 ----
***************
*** 507,518 ****
      }
  
-   // loop over current function blockers and record them
-   for (std::list<cmFunctionBlocker *>::iterator pos 
-         = this->FunctionBlockers.begin();
-        pos != this->FunctionBlockers.end(); ++pos)
-     {
-     originalBlockers.insert(*pos);
-     }
- 
    // Now read the input file
    const char *filenametoread= filename;
--- 611,614 ----
***************
*** 561,565 ****
    // add this list file to the list of dependencies
    this->ListFiles.push_back( filenametoread);
!   bool endScopeNicely = true;
    const size_t numberFunctions = cacheFile.Functions.size();
    for(size_t i =0; i < numberFunctions; ++i)
--- 657,667 ----
    // add this list file to the list of dependencies
    this->ListFiles.push_back( filenametoread);
! 
!   // Enforce balanced blocks (if/endif, function/endfunction, etc.).
!   {
!   LexicalPushPop lexScope(this);
!   IncludeScope incScope(this, filenametoread, noPolicyScope);
! 
!   // Run the parsed commands.
    const size_t numberFunctions = cacheFile.Functions.size();
    for(size_t i =0; i < numberFunctions; ++i)
***************
*** 567,595 ****
      cmExecutionStatus status;
      this->ExecuteCommand(cacheFile.Functions[i],status);
!     if (status.GetReturnInvoked() ||
!         cmSystemTools::GetFatalErrorOccured() )
        {
!       // Exit early from processing this file.
!       endScopeNicely = false;
        break;
        }
!     }
! 
!   // send scope ended to and function blockers
!   if (endScopeNicely)
!     {
!     // loop over all function blockers to see if any block this command
!     for (std::list<cmFunctionBlocker *>::iterator pos 
!          = this->FunctionBlockers.begin();
!          pos != this->FunctionBlockers.end(); ++pos)
        {
!       // if this blocker was not in the original then send a
!       // scope ended message
!       if (originalBlockers.find(*pos) == originalBlockers.end())
!         {
!         (*pos)->ScopeEnded(*this);
!         }
        }
      }
  
    // If this is the directory-level CMakeLists.txt file then perform
--- 669,686 ----
      cmExecutionStatus status;
      this->ExecuteCommand(cacheFile.Functions[i],status);
!     if(cmSystemTools::GetFatalErrorOccured())
        {
!       // Exit early due to error.
!       lexScope.Quiet();
!       incScope.Quiet();
        break;
        }
!     if(status.GetReturnInvoked())
        {
!       // Exit early due to return command.
!       break;
        }
      }
+   }
  
    // If this is the directory-level CMakeLists.txt file then perform
***************
*** 597,601 ****
    if(this->ListFileStack.size() == 1)
      {
!     this->EnforceDirectoryLevelRules(endScopeNicely);
      }
  
--- 688,692 ----
    if(this->ListFileStack.size() == 1)
      {
!     this->EnforceDirectoryLevelRules();
      }
  
***************
*** 610,626 ****
  
  //----------------------------------------------------------------------------
! void cmMakefile::EnforceDirectoryLevelRules(bool endScopeNicely)
  {
-   // Enforce policy stack depth.
-   while(this->PolicyStack.size() > 1)
-     {
-     if(endScopeNicely)
-       {
-       this->IssueMessage(cmake::FATAL_ERROR,
-                          "cmake_policy PUSH without matching POP");
-       }
-     this->PopPolicy(false);
-     }
- 
    // Diagnose a violation of CMP0000 if necessary.
    if(this->CheckCMP0000)
--- 701,706 ----
  
  //----------------------------------------------------------------------------
! void cmMakefile::EnforceDirectoryLevelRules()
  {
    // Diagnose a violation of CMP0000 if necessary.
    if(this->CheckCMP0000)
***************
*** 2368,2372 ****
    // loop over all function blockers to see if any block this command
    // evaluate in reverse, this is critical for balanced IF statements etc
!   std::list<cmFunctionBlocker *>::reverse_iterator pos;
    for (pos = this->FunctionBlockers.rbegin();
         pos != this->FunctionBlockers.rend(); ++pos)
--- 2448,2452 ----
    // loop over all function blockers to see if any block this command
    // evaluate in reverse, this is critical for balanced IF statements etc
!   std::vector<cmFunctionBlocker*>::reverse_iterator pos;
    for (pos = this->FunctionBlockers.rbegin();
         pos != this->FunctionBlockers.rend(); ++pos)
***************
*** 2381,2384 ****
--- 2461,2497 ----
  }
  
+ //----------------------------------------------------------------------------
+ void cmMakefile::PushFunctionBlockerBarrier()
+ {
+   this->FunctionBlockerBarriers.push_back(this->FunctionBlockers.size());
+ }
+ 
+ //----------------------------------------------------------------------------
+ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
+ {
+   // Remove any extra entries pushed on the barrier.
+   FunctionBlockersType::size_type barrier =
+     this->FunctionBlockerBarriers.back();
+   while(this->FunctionBlockers.size() > barrier)
+     {
+     cmsys::auto_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
+     this->FunctionBlockers.pop_back();
+     if(reportError)
+       {
+       // Report the context in which the unclosed block was opened.
+       cmListFileContext const& lfc = fb->GetStartingContext();
+       cmOStringStream e;
+       e << "A logical block opening on the line\n"
+         << "  " << lfc << "\n"
+         << "is not closed.";
+       this->IssueMessage(cmake::FATAL_ERROR, e.str());
+       reportError = false;
+       }
+     }
+ 
+   // Remove the barrier.
+   this->FunctionBlockerBarriers.pop_back();
+ }
+ 
  bool cmMakefile::ExpandArguments(
    std::vector<cmListFileArgument> const& inArgs,
***************
*** 2410,2430 ****
  }
  
! void cmMakefile::RemoveFunctionBlocker(const cmListFileFunction& lff)
  {
!   // loop over all function blockers to see if any block this command
!   std::list<cmFunctionBlocker *>::reverse_iterator pos;
!   for (pos = this->FunctionBlockers.rbegin();
!        pos != this->FunctionBlockers.rend(); ++pos)
      {
!     if ((*pos)->ShouldRemove(lff, *this))
        {
        cmFunctionBlocker* b = *pos;
!       this->FunctionBlockers.remove(b);
!       delete b;
!       break;
        }
      }
  
!   return;
  }
  
--- 2523,2590 ----
  }
  
! //----------------------------------------------------------------------------
! void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
  {
!   if(!this->CallStack.empty())
      {
!     // Record the context in which the blocker is created.
!     fb->SetStartingContext(*(this->CallStack.back().Context));
!     }
! 
!   this->FunctionBlockers.push_back(fb);
! }
! 
! cmsys::auto_ptr<cmFunctionBlocker>
! cmMakefile::RemoveFunctionBlocker(cmFunctionBlocker* fb,
!                                   const cmListFileFunction& lff)
! {
!   // Find the function blocker stack barrier for the current scope.
!   // We only remove a blocker whose index is not less than the barrier.
!   FunctionBlockersType::size_type barrier = 0;
!   if(!this->FunctionBlockerBarriers.empty())
!     {
!     barrier = this->FunctionBlockerBarriers.back();
!     }
! 
!   // Search for the function blocker whose scope this command ends.
!   for(FunctionBlockersType::size_type
!         i = this->FunctionBlockers.size(); i > barrier; --i)
!     {
!     std::vector<cmFunctionBlocker*>::iterator pos =
!       this->FunctionBlockers.begin() + (i - 1);
!     if (*pos == fb)
        {
+       // Warn if the arguments do not match, but always remove.
+       if(!(*pos)->ShouldRemove(lff, *this))
+         {
+         cmListFileContext const& lfc = fb->GetStartingContext();
+         cmOStringStream e;
+         e << "A logical block opening on the line\n"
+           << "  " << lfc << "\n"
+           << "closes on the line\n"
+           << "  " << lff << "\n"
+           << "with mis-matching arguments.";
+         this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+         }
        cmFunctionBlocker* b = *pos;
!       this->FunctionBlockers.erase(pos);
!       return cmsys::auto_ptr<cmFunctionBlocker>(b);
        }
      }
  
!   return cmsys::auto_ptr<cmFunctionBlocker>();
! }
! 
! //----------------------------------------------------------------------------
! cmMakefile::LexicalPushPop::LexicalPushPop(cmMakefile* mf):
!   Makefile(mf), ReportError(true)
! {
!   this->Makefile->PushFunctionBlockerBarrier();
! }
! 
! //----------------------------------------------------------------------------
! cmMakefile::LexicalPushPop::~LexicalPushPop()
! {
!   this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
  }
  
***************
*** 2910,2914 ****
      {
      std::vector<std::string> varArgsExpanded;
!     cmSystemTools::ExpandListArgument(value, varArgsExpanded);
      this->SetIncludeDirectories(varArgsExpanded);
      return;
--- 3070,3077 ----
      {
      std::vector<std::string> varArgsExpanded;
!     if(value)
!       {
!       cmSystemTools::ExpandListArgument(value, varArgsExpanded);
!       }
      this->SetIncludeDirectories(varArgsExpanded);
      return;
***************
*** 2918,2922 ****
      {
      std::vector<std::string> varArgsExpanded;
!     cmSystemTools::ExpandListArgument(value, varArgsExpanded);
      this->SetLinkDirectories(varArgsExpanded);
      return;
--- 3081,3088 ----
      {
      std::vector<std::string> varArgsExpanded;
!     if(value)
!       {
!       cmSystemTools::ExpandListArgument(value, varArgsExpanded);
!       }
      this->SetLinkDirectories(varArgsExpanded);
      return;
***************
*** 3123,3126 ****
--- 3289,3293 ----
  }
  
+ //----------------------------------------------------------------------------
  cmTest* cmMakefile::CreateTest(const char* testName)
  {
***************
*** 3551,3559 ****
  {
    // Is the policy set in our stack?
!   for(std::vector<PolicyMap>::reverse_iterator
!         psi = this->PolicyStack.rbegin();
        psi != this->PolicyStack.rend(); ++psi)
      {
!     PolicyMap::const_iterator pse = psi->find(id);
      if(pse != psi->end())
        {
--- 3718,3725 ----
  {
    // Is the policy set in our stack?
!   for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin();
        psi != this->PolicyStack.rend(); ++psi)
      {
!     PolicyStackEntry::const_iterator pse = psi->find(id);
      if(pse != psi->end())
        {
***************
*** 3602,3607 ****
      }
  
!   // Store the setting.
!   this->PolicyStack.back()[id] = status;
  
    // Special hook for presenting compatibility variable as soon as
--- 3768,3779 ----
      }
  
!   // Update the policy stack from the top to the top-most strong entry.
!   bool previous_was_weak = true;
!   for(PolicyStackType::reverse_iterator psi = this->PolicyStack.rbegin();
!       previous_was_weak && psi != this->PolicyStack.rend(); ++psi)
!     {
!     (*psi)[id] = status;
!     previous_was_weak = psi->Weak;
!     }
  
    // Special hook for presenting compatibility variable as soon as
***************
*** 3627,3650 ****
  }
  
! bool cmMakefile::PushPolicy()
  {
    // Allocate a new stack entry.
!   this->PolicyStack.push_back(PolicyMap());
!   return true;
  }
  
! bool cmMakefile::PopPolicy(bool reportError)
  {
!   if(this->PolicyStack.size() == 1)
      {
      if(reportError)
        {
!       cmSystemTools::Error("Attempt to pop the policy stack past "
!                            "it's beginning.");
        }
!     return false;
      }
!   this->PolicyStack.pop_back();
!   return true;
  }
  
--- 3799,3863 ----
  }
  
! //----------------------------------------------------------------------------
! cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m, bool weak,
!                                          cmPolicies::PolicyMap const& pm):
!   Makefile(m), ReportError(true)
! {
!   this->Makefile->PushPolicy(weak, pm);
!   this->Makefile->PushPolicyBarrier();
! }
! 
! //----------------------------------------------------------------------------
! cmMakefile::PolicyPushPop::~PolicyPushPop()
! {
!   this->Makefile->PopPolicyBarrier(this->ReportError);
!   this->Makefile->PopPolicy();
! }
! 
! //----------------------------------------------------------------------------
! void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm)
  {
    // Allocate a new stack entry.
!   this->PolicyStack.push_back(PolicyStackEntry(pm, weak));
  }
  
! //----------------------------------------------------------------------------
! void cmMakefile::PopPolicy()
  {
!   if(this->PolicyStack.size() > this->PolicyBarriers.back())
!     {
!     this->PolicyStack.pop_back();
!     }
!   else
!     {
!     this->IssueMessage(cmake::FATAL_ERROR,
!                        "cmake_policy POP without matching PUSH");
!     }
! }
! 
! //----------------------------------------------------------------------------
! void cmMakefile::PushPolicyBarrier()
! {
!   this->PolicyBarriers.push_back(this->PolicyStack.size());
! }
! 
! //----------------------------------------------------------------------------
! void cmMakefile::PopPolicyBarrier(bool reportError)
! {
!   // Remove any extra entries pushed on the barrier.
!   PolicyStackType::size_type barrier = this->PolicyBarriers.back();
!   while(this->PolicyStack.size() > barrier)
      {
      if(reportError)
        {
!       this->IssueMessage(cmake::FATAL_ERROR,
!                          "cmake_policy PUSH without matching POP");
!       reportError = false;
        }
!     this->PopPolicy();
      }
! 
!   // Remove the barrier.
!   this->PolicyBarriers.pop_back();
  }
  
***************
*** 3663,3664 ****
--- 3876,3889 ----
    return this->GetCMakeInstance()->GetPolicies();
  }
+ 
+ //----------------------------------------------------------------------------
+ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
+ {
+   /* Record the setting of every policy.  */
+   typedef cmPolicies::PolicyID PolicyID;
+   for(PolicyID pid = cmPolicies::CMP0000;
+       pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid+1))
+     {
+     pm[pid] = this->GetPolicyStatus(pid);
+     }
+ }

Index: cmFunctionCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFunctionCommand.h,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C 2 -d -r1.3 -r1.3.2.1
*** cmFunctionCommand.h	23 Jan 2008 15:27:59 -0000	1.3
--- cmFunctionCommand.h	4 Feb 2009 16:44:17 -0000	1.3.2.1
***************
*** 35,39 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<std::string> Args;
--- 35,38 ----
***************
*** 106,110 ****
        "facilitates creating functions with optional arguments. Additionally "
        "ARGV holds the list of all arguments given to the function and ARGN "
!       "holds the list of argument pass the last expected argument.";
      }
  
--- 105,113 ----
        "facilitates creating functions with optional arguments. Additionally "
        "ARGV holds the list of all arguments given to the function and ARGN "
!       "holds the list of argument pass the last expected argument."
!       "\n"
!       "See the cmake_policy() command documentation for the behavior of "
!       "policies inside functions."
!       ;
      }
  

Index: cmCoreTryCompile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCoreTryCompile.cxx,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -C 2 -d -r1.7.2.2 -r1.7.2.3
*** cmCoreTryCompile.cxx	26 Mar 2008 18:08:25 -0000	1.7.2.2
--- cmCoreTryCompile.cxx	4 Feb 2009 16:44:17 -0000	1.7.2.3
***************
*** 311,315 ****
                                          copyFile.c_str()))
          {
!         cmSystemTools::Error("Could not COPY_FILE");
          return -1;
          }
--- 311,319 ----
                                          copyFile.c_str()))
          {
!         cmOStringStream emsg;
!         emsg << "Could not COPY_FILE.\n"
!           << "  OutputFile: '" << this->OutputFile.c_str() << "'\n"
!           << "    copyFile: '" << copyFile.c_str() << "'\n";
!         cmSystemTools::Error(emsg.str().c_str());
          return -1;
          }

Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.36.2.7
retrieving revision 1.36.2.8
diff -C 2 -d -r1.36.2.7 -r1.36.2.8
*** cmFindPackageCommand.cxx	13 Jan 2009 18:03:52 -0000	1.36.2.7
--- cmFindPackageCommand.cxx	4 Feb 2009 16:44:17 -0000	1.36.2.8
***************
*** 65,68 ****
--- 65,69 ----
    this->DebugMode = false;
    this->UseLib64Paths = false;
+   this->PolicyScope = true;
    this->VersionMajor = 0;
    this->VersionMinor = 0;
***************
*** 78,82 ****
    this->CommandDocumentation =
      "  find_package(<package> [version] [EXACT] [QUIET]\n"
!     "               [[REQUIRED|COMPONENTS] [components...]])\n"
      "Finds and loads settings from an external project.  "
      "<package>_FOUND will be set to indicate whether the package was found.  "
--- 79,84 ----
    this->CommandDocumentation =
      "  find_package(<package> [version] [EXACT] [QUIET]\n"
!     "               [[REQUIRED|COMPONENTS] [components...]]\n"
!     "               [NO_POLICY_SCOPE])\n"
      "Finds and loads settings from an external project.  "
      "<package>_FOUND will be set to indicate whether the package was found.  "
***************
*** 117,120 ****
--- 119,123 ----
      "  find_package(<package> [version] [EXACT] [QUIET]\n"
      "               [[REQUIRED|COMPONENTS] [components...]] [NO_MODULE]\n"
+     "               [NO_POLICY_SCOPE]\n"
      "               [NAMES name1 [name2 ...]]\n"
      "               [CONFIGS config1 [config2 ...]]\n"
***************
*** 156,161 ****
      "is not found a fatal error is generated and the configure step stops "
      "executing.  If <package>_DIR has been set to a directory not containing "
!     "a configuration file a fatal error is always generated because user "
!     "intervention is required."
      "\n"
      "When the [version] argument is given Config mode will only find a "
--- 159,163 ----
      "is not found a fatal error is generated and the configure step stops "
      "executing.  If <package>_DIR has been set to a directory not containing "
!     "a configuration file CMake will ignore it and search from scratch."
      "\n"
      "When the [version] argument is given Config mode will only find a "
***************
*** 292,295 ****
--- 294,302 ----
    this->CommandDocumentation += this->GenericDocumentationRootPath;
    this->CommandDocumentation += this->GenericDocumentationPathsOrder;
+   this->CommandDocumentation +=
+     "\n"
+     "See the cmake_policy() command documentation for discussion of the "
+     "NO_POLICY_SCOPE option."
+     ;
  }
  
***************
*** 408,411 ****
--- 415,424 ----
        doing = DoingConfigs;
        }
+     else if(args[i] == "NO_POLICY_SCOPE")
+       {
+       this->PolicyScope = false;
+       this->Compatibility_1_6 = false;
+       doing = DoingNone;
+       }
      else if(args[i] == "NO_CMAKE_BUILDS_PATH")
        {
***************
*** 677,681 ****
      var += "_FIND_MODULE";
      this->Makefile->AddDefinition(var.c_str(), "1");
!     bool result = this->ReadListFile(mfile.c_str());
      this->Makefile->RemoveDefinition(var.c_str());
      return result;
--- 690,694 ----
      var += "_FIND_MODULE";
      this->Makefile->AddDefinition(var.c_str(), "1");
!     bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope);
      this->Makefile->RemoveDefinition(var.c_str());
      return result;
***************
*** 755,759 ****
  
      // Parse the configuration file.
!     if(this->ReadListFile(this->FileFound.c_str()))
        {
        // The package has been found.
--- 768,772 ----
  
      // Parse the configuration file.
!     if(this->ReadListFile(this->FileFound.c_str(), DoPolicyScope))
        {
        // The package has been found.
***************
*** 965,971 ****
  
  //----------------------------------------------------------------------------
! bool cmFindPackageCommand::ReadListFile(const char* f)
  {
!   if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),f))
      {
      return true;
--- 978,985 ----
  
  //----------------------------------------------------------------------------
! bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
  {
!   if(this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), f, 0,
!                                   !this->PolicyScope || psr == NoPolicyScope))
      {
      return true;
***************
*** 1279,1284 ****
  {
    // The version file will be loaded in an isolated scope.
!   this->Makefile->PushScope();
!   this->Makefile->PushPolicy();
  
    // Clear the output variables.
--- 1293,1300 ----
  {
    // The version file will be loaded in an isolated scope.
!   cmMakefile::ScopePushPop varScope(this->Makefile);
!   cmMakefile::PolicyPushPop polScope(this->Makefile);
!   static_cast<void>(varScope);
!   static_cast<void>(polScope);
  
    // Clear the output variables.
***************
*** 1304,1310 ****
    this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf);
  
!   // Load the version check file.
    bool suitable = false;
!   if(this->ReadListFile(version_file.c_str()))
      {
      // Check the output variables.
--- 1320,1327 ----
    this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf);
  
!   // Load the version check file.  Pass NoPolicyScope because we do
!   // our own policy push/pop independent of CMP0011.
    bool suitable = false;
!   if(this->ReadListFile(version_file.c_str(), NoPolicyScope))
      {
      // Check the output variables.
***************
*** 1346,1353 ****
      }
  
-   // Restore the original scope.
-   this->Makefile->PopPolicy();
-   this->Makefile->PopScope();
- 
    // Succeed if the version is suitable.
    return suitable;
--- 1363,1366 ----

--- NEW FILE: cmUnsetCommand.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmUnsetCommand.h,v $
  Language:  C++
  Date:      $Date: 2009-02-04 16:44:17 $
  Version:   $Revision: 1.1.2.2 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef cmUnsetCommand_h
#define cmUnsetCommand_h

#include "cmCommand.h"

/** \class cmUnsetCommand
 * \brief Unset a CMAKE variable
 *
 * cmUnsetCommand unsets or removes a variable.
 */
class cmUnsetCommand : public cmCommand
{
public:
  /**
   * This is a virtual constructor for the command.
   */
  virtual cmCommand* Clone()
    {
    return new cmUnsetCommand;
    }

  /**
   * This is called when the command is first encountered in
   * the CMakeLists.txt file.
   */
  virtual bool InitialPass(std::vector<std::string> const& args,
                           cmExecutionStatus &status);

  /**
   * This determines if the command is invoked when in script mode.
   */
  virtual bool IsScriptable() { return true; }

  /**
   * The name of the command as specified in CMakeList.txt.
   */
  virtual const char* GetName() {return "unset";}

  /**
   * Succinct documentation.
   */
  virtual const char* GetTerseDocumentation()
    {
    return "Unset a variable, cache variable, or environment variable.";
    }

  /**
   * More documentation.
   */
  virtual const char* GetFullDocumentation()
    {
    return
      "  unset(<variable> [CACHE])\n"
      "Removes the specified variable causing it to become undefined.  "
      "If CACHE is present then the variable is removed from the cache "
      "instead of the current scope.\n"
      "<variable> can be an environment variable such as:\n"
      "  unset(ENV{LD_LIBRARY_PATH})\n"
      "in which case the variable will be removed from the current "
      "environment.";
    }

  cmTypeMacro(cmUnsetCommand, cmCommand);
};



#endif

Index: cmGlobalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio7Generator.cxx,v
retrieving revision 1.99.2.3
retrieving revision 1.99.2.4
diff -C 2 -d -r1.99.2.3 -r1.99.2.4
*** cmGlobalVisualStudio7Generator.cxx	24 Oct 2008 15:18:46 -0000	1.99.2.3
--- cmGlobalVisualStudio7Generator.cxx	4 Feb 2009 16:44:17 -0000	1.99.2.4
***************
*** 254,266 ****
      if(!this->IsExcluded(root, *t))
        {
!       if (t->GetType() == cmTarget::UTILITY ||
!           t->GetType() == cmTarget::GLOBAL_TARGET)
!         {
!         target->AddUtility(t->GetName());
!         }
!       else
!         {
!         target->AddLinkLibrary(t->GetName(),cmTarget::GENERAL);
!         }
        }
      }
--- 254,258 ----
      if(!this->IsExcluded(root, *t))
        {
!       target->AddUtility(t->GetName());
        }
      }
***************
*** 270,281 ****
    std::ostream& fout, 
    cmLocalGenerator* root,
!   cmGlobalGenerator::TargetDependSet& projectTargets)
  {
    // loop over again and write out configurations for each target
    // in the solution
!   for(cmGlobalGenerator::TargetDependSet::iterator tt =
          projectTargets.begin(); tt != projectTargets.end(); ++tt)
      {
!     cmTarget* target = const_cast<cmTarget*>(*tt);
      if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
        {
--- 262,273 ----
    std::ostream& fout, 
    cmLocalGenerator* root,
!   OrderedTargetDependSet const& projectTargets)
  {
    // loop over again and write out configurations for each target
    // in the solution
!   for(OrderedTargetDependSet::const_iterator tt =
          projectTargets.begin(); tt != projectTargets.end(); ++tt)
      {
!     cmTarget* target = *tt;
      if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
        {
***************
*** 305,309 ****
      std::ostream& fout,
      cmLocalGenerator* root,
!     cmGlobalGenerator::TargetDependSet& projectTargets,
      cmGlobalGenerator::TargetDependSet& originalTargets
      )
--- 297,301 ----
      std::ostream& fout,
      cmLocalGenerator* root,
!     OrderedTargetDependSet const& projectTargets,
      cmGlobalGenerator::TargetDependSet& originalTargets
      )
***************
*** 311,318 ****
    std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
    rootdir += "/";
!   for(cmGlobalGenerator::TargetDependSet::iterator tt =
          projectTargets.begin(); tt != projectTargets.end(); ++tt)
      {
!     cmTarget* target = const_cast<cmTarget*>(*tt);
      cmMakefile* mf = target->GetMakefile();
      // look for the all_build rule and add depends to all
--- 303,310 ----
    std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
    rootdir += "/";
!   for(OrderedTargetDependSet::const_iterator tt =
          projectTargets.begin(); tt != projectTargets.end(); ++tt)
      {
!     cmTarget* target = *tt;
      cmMakefile* mf = target->GetMakefile();
      // look for the all_build rule and add depends to all
***************
*** 371,381 ****
  void cmGlobalVisualStudio7Generator::WriteTargetDepends(
      std::ostream& fout,
!     cmGlobalGenerator::TargetDependSet& projectTargets
      )
  {
!   for(cmGlobalGenerator::TargetDependSet::iterator tt =
          projectTargets.begin(); tt != projectTargets.end(); ++tt)
      {
!     cmTarget* target = const_cast<cmTarget*>(*tt);
      cmMakefile* mf = target->GetMakefile();
      if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
--- 363,373 ----
  void cmGlobalVisualStudio7Generator::WriteTargetDepends(
      std::ostream& fout,
!     OrderedTargetDependSet const& projectTargets
      )
  {
!   for(OrderedTargetDependSet::const_iterator tt =
          projectTargets.begin(); tt != projectTargets.end(); ++tt)
      {
!     cmTarget* target = *tt;
      cmMakefile* mf = target->GetMakefile();
      if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
***************
*** 435,439 ****
                        originalTargets,
                        root, generators);
!   this->WriteTargetsToSolution(fout, root, projectTargets, originalTargets);
    // Write out the configurations information for the solution
    fout << "Global\n"
--- 427,433 ----
                        originalTargets,
                        root, generators);
!   OrderedTargetDependSet orderedProjectTargets(projectTargets);
!   this->WriteTargetsToSolution(fout, root, orderedProjectTargets,
!                                originalTargets);
    // Write out the configurations information for the solution
    fout << "Global\n"
***************
*** 450,459 ****
    // Write out project(target) depends 
    fout << "\tGlobalSection(ProjectDependencies) = postSolution\n";
!   this->WriteTargetDepends(fout, projectTargets);
    fout << "\tEndGlobalSection\n";
  
    // Write out the configurations for all the targets in the project
    fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
!   this->WriteTargetConfigurations(fout, root, projectTargets);
    fout << "\tEndGlobalSection\n";
  
--- 444,453 ----
    // Write out project(target) depends 
    fout << "\tGlobalSection(ProjectDependencies) = postSolution\n";
!   this->WriteTargetDepends(fout, orderedProjectTargets);
    fout << "\tEndGlobalSection\n";
  
    // Write out the configurations for all the targets in the project
    fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
!   this->WriteTargetConfigurations(fout, root, orderedProjectTargets);
    fout << "\tEndGlobalSection\n";
  
***************
*** 732,735 ****
--- 726,757 ----
  
  //----------------------------------------------------------------------------
+ bool
+ cmGlobalVisualStudio7Generator::TargetCompare
+ ::operator()(cmTarget const* l, cmTarget const* r)
+ {
+   // Make sure ALL_BUILD is first so it is the default active project.
+   if(strcmp(r->GetName(), "ALL_BUILD") == 0)
+     {
+     return false;
+     }
+   if(strcmp(l->GetName(), "ALL_BUILD") == 0)
+     {
+     return true;
+     }
+   return strcmp(l->GetName(), r->GetName()) < 0;
+ }
+ 
+ //----------------------------------------------------------------------------
+ cmGlobalVisualStudio7Generator::OrderedTargetDependSet
+ ::OrderedTargetDependSet(cmGlobalGenerator::TargetDependSet const& targets)
+ {
+   for(cmGlobalGenerator::TargetDependSet::const_iterator ti =
+         targets.begin(); ti != targets.end(); ++ti)
+     {
+     this->insert(*ti);
+     }
+ }
+ 
+ //----------------------------------------------------------------------------
  static cmVS7FlagTable cmVS7ExtraFlagTable[] =
  {

Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.10.2.7
retrieving revision 1.10.2.8
diff -C 2 -d -r1.10.2.7 -r1.10.2.8
*** cmPolicies.h	24 Oct 2008 15:18:54 -0000	1.10.2.7
--- cmPolicies.h	4 Feb 2009 16:44:17 -0000	1.10.2.8
***************
*** 52,55 ****
--- 52,56 ----
      CMP0009, // GLOB_RECURSE should not follow symlinks by default
      CMP0010, // Bad variable reference syntax is an error
+     CMP0011, // Strong policy scope for include and find_package
  
      // Always the last entry.  Useful mostly to avoid adding a comma
***************
*** 90,93 ****
--- 91,97 ----
    void GetDocumentation(std::vector<cmDocumentationEntry>& v);
  
+   /** Represent a set of policy values.  */
+   typedef std::map<PolicyID, PolicyStatus> PolicyMap;
+ 
    private:
    // might have to make these internal for VS6 not sure yet

Index: cmMacroCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMacroCommand.h,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -C 2 -d -r1.16 -r1.16.2.1
*** cmMacroCommand.h	23 Jan 2008 15:27:59 -0000	1.16
--- cmMacroCommand.h	4 Feb 2009 16:44:17 -0000	1.16.2.1
***************
*** 35,39 ****
                                   cmExecutionStatus &);
    virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
-   virtual void ScopeEnded(cmMakefile &mf);
    
    std::vector<std::string> Args;
--- 35,38 ----
***************
*** 113,117 ****
        "replacements much like the c preprocessor would do with a "
        "macro. If you want true CMake variables you should look at "
!       "the function command.";
      }
  
--- 112,120 ----
        "replacements much like the c preprocessor would do with a "
        "macro. If you want true CMake variables you should look at "
!       "the function command."
!       "\n"
!       "See the cmake_policy() command documentation for the behavior of "
!       "policies inside macros."
!       ;
      }
  

Index: cmCMakePolicyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCMakePolicyCommand.cxx,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C 2 -d -r1.2.2.2 -r1.2.2.3
*** cmCMakePolicyCommand.cxx	3 Sep 2008 13:43:16 -0000	1.2.2.2
--- cmCMakePolicyCommand.cxx	4 Feb 2009 16:44:16 -0000	1.2.2.3
***************
*** 44,48 ****
        return false;
        }
!     return this->Makefile->PushPolicy();
      }
    else if(args[0] == "POP")
--- 44,49 ----
        return false;
        }
!     this->Makefile->PushPolicy();
!     return true;
      }
    else if(args[0] == "POP")
***************
*** 53,65 ****
        return false;
        }
!     if(this->Makefile->PopPolicy(false))
!       {
!       return true;
!       }
!     else
!       {
!       this->SetError("POP without matching PUSH");
!       return false;
!       }
      }
    else if(args[0] == "VERSION")
--- 54,59 ----
        return false;
        }
!     this->Makefile->PopPolicy();
!     return true;
      }
    else if(args[0] == "VERSION")

Index: cmMacroCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMacroCommand.cxx,v
retrieving revision 1.36.2.1
retrieving revision 1.36.2.2
diff -C 2 -d -r1.36.2.1 -r1.36.2.2
*** cmMacroCommand.cxx	24 Oct 2008 15:18:52 -0000	1.36.2.1
--- cmMacroCommand.cxx	4 Feb 2009 16:44:17 -0000	1.36.2.2
***************
*** 37,40 ****
--- 37,41 ----
      newC->Args = this->Args;
      newC->Functions = this->Functions;
+     newC->Policies = this->Policies;
      return newC;
    }
***************
*** 82,85 ****
--- 83,87 ----
    std::vector<std::string> Args;
    std::vector<cmListFileFunction> Functions;
+   cmPolicies::PolicyMap Policies;
  };
  
***************
*** 108,111 ****
--- 110,120 ----
      }
  
+   // Enforce matching logical blocks inside the macro.
+   cmMakefile::LexicalPushPop lexScope(this->Makefile);
+ 
+   // Push a weak policy scope which restores the policies recorded at
+   // macro creation.
+   cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
+ 
    // set the value of argc
    cmOStringStream argcDefStream;
***************
*** 216,219 ****
--- 225,230 ----
        // The error message should have already included the call stack
        // so we do not need to report an error here.
+       lexScope.Quiet();
+       polScope.Quiet();
        inStatus.SetNestedError(true);
        return false;
***************
*** 261,264 ****
--- 272,276 ----
        f->Args = this->Args;
        f->Functions = this->Functions;
+       mf.RecordPolicies(f->Policies);
        std::string newName = "_" + this->Args[0];
        mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(), 
***************
*** 267,271 ****
  
        // remove the function blocker now that the macro is defined
!       mf.RemoveFunctionBlocker(lff);
        return true;
        }
--- 279,283 ----
  
        // remove the function blocker now that the macro is defined
!       mf.RemoveFunctionBlocker(this, lff);
        return true;
        }
***************
*** 303,317 ****
  }
  
- void cmMacroFunctionBlocker::
- ScopeEnded(cmMakefile &mf)
- {
-   // macros should end with an EndMacro
-   cmSystemTools::Error(
-     "The end of a CMakeLists file was reached with a MACRO statement that "
-     "was not closed properly. Within the directory: ",
-     mf.GetCurrentDirectory(), " with macro ",
-     this->Args[0].c_str());
- }
- 
  bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
                                   cmExecutionStatus &)
--- 315,318 ----

--- NEW FILE: cmUnsetCommand.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmUnsetCommand.cxx,v $
  Language:  C++
  Date:      $Date: 2009-02-04 16:44:17 $
  Version:   $Revision: 1.1.2.2 $

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmUnsetCommand.h"

// cmUnsetCommand
bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
                                 cmExecutionStatus &)
{
  if(args.size() < 1 || args.size() > 2)
    {
    this->SetError("called with incorrect number of arguments");
    return false;
    }

  const char* variable = args[0].c_str();

  // unset(ENV{VAR})
  if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5)
    {
    // what is the variable name
    char *envVarName = new char [strlen(variable)];
    strncpy(envVarName,variable+4,strlen(variable)-5);
    envVarName[strlen(variable)-5] = '\0';

#ifdef CMAKE_BUILD_WITH_CMAKE
    cmSystemTools::UnsetEnv(envVarName);
#endif
    delete[] envVarName;
    return true;
    }
  // unset(VAR)
  else if (args.size() == 1)
    {
    this->Makefile->RemoveDefinition(variable);
    return true;
    }
  // unset(VAR CACHE)
  else if ((args.size() == 2) && (args[1] == "CACHE"))
    {
    this->Makefile->RemoveCacheDefinition(variable);
    return true;
    }
  // ERROR: second argument isn't CACHE
  else
    {
    this->SetError("called with an invalid second argument");
    return false;
    }
}


Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.230.2.7
retrieving revision 1.230.2.8
diff -C 2 -d -r1.230.2.7 -r1.230.2.8
*** cmMakefile.h	15 Jan 2009 14:17:20 -0000	1.230.2.7
--- cmMakefile.h	4 Feb 2009 16:44:17 -0000	1.230.2.8
***************
*** 32,35 ****
--- 32,36 ----
  #endif
  
+ #include <cmsys/auto_ptr.hxx>
  #include <cmsys/RegularExpression.hxx>
  
***************
*** 44,47 ****
--- 45,49 ----
  class cmake;
  class cmMakefileCall;
+ class cmCMakePolicyCommand;
  
  /** \class cmMakefile
***************
*** 83,96 ****
    bool ReadListFile(const char* listfile, 
                      const char* external= 0, 
!                     std::string* fullPath= 0); 
  
    /**
     * Add a function blocker to this makefile
     */
!   void AddFunctionBlocker(cmFunctionBlocker *fb)
!     { this->FunctionBlockers.push_back(fb);}
!   void RemoveFunctionBlocker(cmFunctionBlocker *fb)
!     { this->FunctionBlockers.remove(fb);}
!   void RemoveFunctionBlocker(const cmListFileFunction& lff);
  
    /**
--- 85,115 ----
    bool ReadListFile(const char* listfile, 
                      const char* external= 0, 
!                     std::string* fullPath= 0,
!                     bool noPolicyScope = true);
  
    /**
     * Add a function blocker to this makefile
     */
!   void AddFunctionBlocker(cmFunctionBlocker* fb);
! 
!   /**
!    * Remove the function blocker whose scope ends with the given command.
!    * This returns ownership of the function blocker object.
!    */
!   cmsys::auto_ptr<cmFunctionBlocker>
!   RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
! 
!   /** Push/pop a lexical (function blocker) barrier automatically.  */
!   class LexicalPushPop
!   {
!   public:
!     LexicalPushPop(cmMakefile* mf);
!     ~LexicalPushPop();
!     void Quiet() { this->ReportError = false; }
!   private:
!     cmMakefile* Makefile;
!     bool ReportError;
!   };
!   friend class LexicalPushPop;
  
    /**
***************
*** 325,333 ****
    bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
    cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
-   bool PushPolicy();
-   bool PopPolicy(bool reportError = true);
    bool SetPolicyVersion(const char *version);
    //@}
  
    /**
      * Get the Policies Instance
--- 344,366 ----
    bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
    cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
    bool SetPolicyVersion(const char *version);
+   void RecordPolicies(cmPolicies::PolicyMap& pm);
    //@}
  
+   /** Helper class to push and pop policies automatically.  */
+   class PolicyPushPop
+   {
+   public:
+     PolicyPushPop(cmMakefile* m,
+                   bool weak = false,
+                   cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
+     ~PolicyPushPop();
+     void Quiet() { this->ReportError = false; }
+   private:
+     cmMakefile* Makefile;
+     bool ReportError;
+   };
+   friend class PolicyPushPop;
+ 
    /**
      * Get the Policies Instance
***************
*** 872,876 ****
  
    void AddDefaultDefinitions();
!   std::list<cmFunctionBlocker *> FunctionBlockers;
  
    typedef std::map<cmStdString, cmData*> DataMapType;
--- 905,913 ----
  
    void AddDefaultDefinitions();
!   typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
!   FunctionBlockersType FunctionBlockers;
!   std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers;
!   void PushFunctionBlockerBarrier();
!   void PopFunctionBlockerBarrier(bool reportError = true);
  
    typedef std::map<cmStdString, cmData*> DataMapType;
***************
*** 909,917 ****
    std::vector<cmTarget*> ImportedTargetsOwned;
    std::map<cmStdString, cmTarget*> ImportedTargets;
!   
    // stack of policy settings
!   typedef std::map<cmPolicies::PolicyID,
!                    cmPolicies::PolicyStatus> PolicyMap;
!   std::vector<PolicyMap> PolicyStack;
    cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id);
  
--- 946,972 ----
    std::vector<cmTarget*> ImportedTargetsOwned;
    std::map<cmStdString, cmTarget*> ImportedTargets;
! 
!   // Internal policy stack management.
!   void PushPolicy(bool weak = false,
!                   cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
!   void PopPolicy();
!   void PushPolicyBarrier();
!   void PopPolicyBarrier(bool reportError = true);
!   friend class cmCMakePolicyCommand;
!   class IncludeScope;
!   friend class IncludeScope;
! 
    // stack of policy settings
!   struct PolicyStackEntry: public cmPolicies::PolicyMap
!   {
!     typedef cmPolicies::PolicyMap derived;
!     PolicyStackEntry(bool w = false): derived(), Weak(w) {}
!     PolicyStackEntry(derived const& d, bool w = false): derived(d), Weak(w) {}
!     PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
!     bool Weak;
!   };
!   typedef std::vector<PolicyStackEntry> PolicyStackType;
!   PolicyStackType PolicyStack;
!   std::vector<PolicyStackType::size_type> PolicyBarriers;
    cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id);
  
***************
*** 919,925 ****
  
    // Enforce rules about CMakeLists.txt files.
!   void EnforceDirectoryLevelRules(bool endScopeNicely);
  };
  
  
  #endif
--- 974,999 ----
  
    // Enforce rules about CMakeLists.txt files.
!   void EnforceDirectoryLevelRules();
  };
  
+ //----------------------------------------------------------------------------
+ // Helper class to make sure the call stack is valid.
+ class cmMakefileCall
+ {
+ public:
+   cmMakefileCall(cmMakefile* mf,
+                  cmListFileContext const& lfc,
+                  cmExecutionStatus& status): Makefile(mf)
+     {
+     cmMakefile::CallStackEntry entry = {&lfc, &status};
+     this->Makefile->CallStack.push_back(entry);
+     }
+   ~cmMakefileCall()
+     {
+     this->Makefile->CallStack.pop_back();
+     }
+ private:
+   cmMakefile* Makefile;
+ };
  
  #endif

Index: cmIncludeCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIncludeCommand.h,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -C 2 -d -r1.17 -r1.17.2.1
*** cmIncludeCommand.h	23 Jan 2008 15:27:59 -0000	1.17
--- cmIncludeCommand.h	4 Feb 2009 16:44:17 -0000	1.17.2.1
***************
*** 70,75 ****
      {
      return
!       "  include(file1 [OPTIONAL] [RESULT_VARIABLE <VAR>])\n"
!       "  include(module [OPTIONAL] [RESULT_VARIABLE <VAR>])\n"
        "Reads CMake listfile code from the given file.  Commands in the file "
        "are processed immediately as if they were written in place of the "
--- 70,75 ----
      {
      return
!       "  include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]\n"
!       "                        [NO_POLICY_SCOPE])\n"
        "Reads CMake listfile code from the given file.  Commands in the file "
        "are processed immediately as if they were written in place of the "
***************
*** 79,83 ****
        "has been included or NOTFOUND if it failed.\n"
        "If a module is specified instead of a file, the file with name "
!       "<modulename>.cmake is searched in the CMAKE_MODULE_PATH.";
      }
    
--- 79,87 ----
        "has been included or NOTFOUND if it failed.\n"
        "If a module is specified instead of a file, the file with name "
!       "<modulename>.cmake is searched in the CMAKE_MODULE_PATH."
!       "\n"
!       "See the cmake_policy() command documentation for discussion of the "
!       "NO_POLICY_SCOPE option."
!       ;
      }
    



More information about the Cmake-commits mailing list