[Cmake-commits] CMake branch, next, updated. v2.8.3-1167-gf0e44c1

Brad King brad.king at kitware.com
Tue Jan 4 08:11:31 EST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  f0e44c18ab6840912356f014ed6062ae1ba1fcf0 (commit)
       via  a364daf1fd1fd9079fdc13bec4fe8ea2a56efe04 (commit)
       via  8e45c1128cd6546a87d7ee32ace91950016f5233 (commit)
      from  95c45241560212ad77cd6ae47d4bea322f218dc0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0e44c18ab6840912356f014ed6062ae1ba1fcf0
commit f0e44c18ab6840912356f014ed6062ae1ba1fcf0
Merge: 95c4524 a364daf
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 4 08:11:19 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jan 4 08:11:19 2011 -0500

    Merge topic 'user-policy-defaults' into next
    
    a364daf Allow users to specify defaults for unset policies
    8e45c11 Fix indentation in cmPolicies::ApplyPolicyVersion()


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a364daf1fd1fd9079fdc13bec4fe8ea2a56efe04
commit a364daf1fd1fd9079fdc13bec4fe8ea2a56efe04
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jan 3 18:04:58 2011 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 4 07:46:10 2011 -0500

    Allow users to specify defaults for unset policies
    
    Check CMAKE_POLICY_DEFAULT_CMP<NNNN> for a default when policy CMP<NNNN>
    would otherwise be left unset.  This allows users to set policies on the
    command line when the project does not set them.  One may do this to
    quiet warnings or test whether a project will build with new behavior
    without modifying code.  There may also be cases when users want to
    build an existing project release using new behavior for policies
    unknown to the project at the time of the release.

diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h
index b326865..afd3001 100644
--- a/Source/cmCMakePolicyCommand.h
+++ b/Source/cmCMakePolicyCommand.h
@@ -85,7 +85,8 @@ public:
       "given version of CMake.  "
       "All policies introduced in the specified version or earlier "
       "will be set to use NEW behavior.  "
-      "All policies introduced after the specified version will be unset.  "
+      "All policies introduced after the specified version will be unset "
+      "(unless variable CMAKE_POLICY_DEFAULT_CMP<NNNN> sets a default).  "
       "This effectively requests behavior preferred as of a given CMake "
       "version and tells newer CMake versions to warn about their new "
       "policies.  "
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx
index a69bb8f..5dfa64e 100644
--- a/Source/cmDocumentVariables.cxx
+++ b/Source/cmDocumentVariables.cxx
@@ -464,6 +464,25 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
 
   // Variables defined by cmake, that change the behavior
   // of cmake
+
+  cm->DefineProperty
+    ("CMAKE_POLICY_DEFAULT_CMP<NNNN>",  cmProperty::VARIABLE,
+     "Default for CMake Policy CMP<NNNN> when it is otherwise left unset.",
+     "Commands cmake_minimum_required(VERSION) and cmake_policy(VERSION) "
+     "by default leave policies introduced after the given version unset.  "
+     "Set CMAKE_POLICY_DEFAULT_CMP<NNNN> to OLD or NEW to specify the "
+     "default for policy CMP<NNNN>, where <NNNN> is the policy number."
+     "\n"
+     "This variable should not be set by a project in CMake code; "
+     "use cmake_policy(SET) instead.  "
+     "Users running CMake may set this variable in the cache "
+     "(e.g. -DCMAKE_POLICY_DEFAULT_CMP<NNNN>=<OLD|NEW>) "
+     "to set a policy not otherwise set by the project.  "
+     "Set to OLD to quiet a policy warning while using old behavior "
+     "or to NEW to try building the project with new behavior.",
+     false,
+     "Variables That Change Behavior");
+
     cm->DefineProperty
     ("CMAKE_FIND_LIBRARY_PREFIXES",  cmProperty::VARIABLE,
      "Prefixes to prepend when looking for libraries.",
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index d147a3b..fccf0cc 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -565,9 +565,14 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
         {
         ancientPolicies.push_back(i->first);
         }
-      else if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN))
+      else
         {
-        return false;
+        cmPolicies::PolicyStatus status = cmPolicies::WARN;
+        if(!this->GetPolicyDefault(mf, i->second->IDString, &status) ||
+           !mf->SetPolicy(i->second->ID, status))
+          {
+          return false;
+          }
         }
       }
     else
@@ -591,6 +596,36 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
   return true;
 }
 
+//----------------------------------------------------------------------------
+bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
+                                  cmPolicies::PolicyStatus* defaultSetting)
+{
+  std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
+  std::string defaultValue = mf->GetSafeDefinition(defaultVar.c_str());
+  if(defaultValue == "NEW")
+    {
+    *defaultSetting = cmPolicies::NEW;
+    }
+  else if(defaultValue == "OLD")
+    {
+    *defaultSetting = cmPolicies::OLD;
+    }
+  else if(defaultValue == "")
+    {
+    *defaultSetting = cmPolicies::WARN;
+    }
+  else
+    {
+    cmOStringStream e;
+    e << defaultVar << " has value \"" << defaultValue
+      << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
+    mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return false;
+    }
+
+  return true;
+}
+
 bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
 {
   if (!id || strlen(id) < 1)
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index fce33ac..87eb646 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -102,6 +102,10 @@ public:
   void DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
                                unsigned int majorVer, unsigned int minorVer,
                                unsigned int patchVer, cmMakefile* mf);
+
+  bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
+                        cmPolicies::PolicyStatus* defaultStatus);
+
 };
 
 #endif
diff --git a/Tests/PolicyScope/CMakeLists.txt b/Tests/PolicyScope/CMakeLists.txt
index 89a89ee..e6f2edc 100644
--- a/Tests/PolicyScope/CMakeLists.txt
+++ b/Tests/PolicyScope/CMakeLists.txt
@@ -82,5 +82,23 @@ cmake_policy(GET CMP0002 cmp)
 check(CMP0002 "OLD" "${cmp}")
 
 #-----------------------------------------------------------------------------
+# Test CMAKE_POLICY_DEFAULT_CMP<NNNN> variable.
+cmake_policy(PUSH)
+  set(CMAKE_POLICY_DEFAULT_CMP0010 OLD) # ignored
+  set(CMAKE_POLICY_DEFAULT_CMP0012 OLD) # honored
+  set(CMAKE_POLICY_DEFAULT_CMP0013 NEW) # honored
+  set(CMAKE_POLICY_DEFAULT_CMP0014 "")  # noop
+  cmake_policy(VERSION 2.6.3)
+  cmake_policy(GET CMP0010 cmp)
+  check(CMP0010 "NEW" "${cmp}")
+  cmake_policy(GET CMP0012 cmp)
+  check(CMP0012 "OLD" "${cmp}")
+  cmake_policy(GET CMP0013 cmp)
+  check(CMP0013 "NEW" "${cmp}")
+  cmake_policy(GET CMP0014 cmp)
+  check(CMP0014 "" "${cmp}")
+cmake_policy(POP)
+
+#-----------------------------------------------------------------------------
 # Dummy executable so the project can build and run.
 add_executable(PolicyScope main.c)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8e45c1128cd6546a87d7ee32ace91950016f5233
commit 8e45c1128cd6546a87d7ee32ace91950016f5233
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 23 21:53:35 2010 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Jan 4 07:42:49 2011 -0500

    Fix indentation in cmPolicies::ApplyPolicyVersion()
    
    Alex

diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 3fe92de..d147a3b 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -495,9 +495,9 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
   std::string ver = "2.4.0";
 
   if (version && strlen(version) > 0)
-  {
+    {
     ver = version;
-  }
+    }
 
   unsigned int majorVer = 2;
   unsigned int minorVer = 0;
@@ -556,29 +556,28 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
 
   // now loop over all the policies and set them as appropriate
   std::vector<cmPolicies::PolicyID> ancientPolicies;
-  std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
-    = this->Policies.begin();
-  for (;i != this->Policies.end(); ++i)
-  {
-  if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer,tweakVer))
+  for(std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
+                     = this->Policies.begin(); i != this->Policies.end(); ++i)
     {
-      if(i->second->Status == cmPolicies::REQUIRED_ALWAYS)
+    if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer,tweakVer))
       {
+      if(i->second->Status == cmPolicies::REQUIRED_ALWAYS)
+        {
         ancientPolicies.push_back(i->first);
-      }
+        }
       else if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN))
-      {
+        {
         return false;
+        }
       }
-    }
     else
-    {
-      if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW))
       {
+      if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW))
+        {
         return false;
+        }
       }
     }
-  }
 
   // Make sure the project does not use any ancient policies.
   if(!ancientPolicies.empty())

-----------------------------------------------------------------------

Summary of changes:
 Source/cmCMakePolicyCommand.h    |    3 +-
 Source/cmDocumentVariables.cxx   |   19 +++++++++++
 Source/cmPolicies.cxx            |   66 ++++++++++++++++++++++++++++---------
 Source/cmPolicies.h              |    4 ++
 Tests/PolicyScope/CMakeLists.txt |   18 ++++++++++
 5 files changed, 93 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list