[Cmake-commits] CMake branch, next, updated. v2.8.3-891-gfc40262

Alexander Neundorf neundorf at kde.org
Tue Dec 14 16:44:19 EST 2010


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  fc4026227e2abaef0de9a7843bf8f528b503cabb (commit)
       via  a924ee511a33963fdce693b77982131df481df8f (commit)
       via  3e8559879e983bd5857f521a4b3274eea6387ccd (commit)
       via  364530c94ec1f81f21fda6771a23670fe7e0a6bb (commit)
       via  eb74f519e90d880ed895ea2243aae2d64c2ba8f4 (commit)
       via  15712e2be89983e6be8a3d4b3a20966163266c00 (commit)
       via  07410f329d8a219fc8c6153212cdcdb6034ab27c (commit)
      from  a9808eeba7a31ebe404f92c7a4add539155036cd (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=fc4026227e2abaef0de9a7843bf8f528b503cabb
commit fc4026227e2abaef0de9a7843bf8f528b503cabb
Merge: a9808ee a924ee5
Author:     Alexander Neundorf <neundorf at kde.org>
AuthorDate: Tue Dec 14 16:44:17 2010 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Dec 14 16:44:17 2010 -0500

    Merge topic 'PreferCMakeModulesByCMakeModulesWithPolicy-NoTrailingWhitespaceCommit' into next
    
    a924ee5 Add comment about CMP0017 to docs of include()
    3e85598 Remove trailing whitespace
    364530c Remove trailing whitespace
    eb74f51 Add support for CMAKE_POLICY_DEFAULT_CMP<NNNN> variables.
    15712e2 Fix indentation in cmPolicies::ApplyPolicyVersion()
    07410f3 Prefer files from CMAKE_ROOT when including from CMAKE_ROOT.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a924ee511a33963fdce693b77982131df481df8f
commit a924ee511a33963fdce693b77982131df481df8f
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Dec 14 22:38:33 2010 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Dec 14 22:38:33 2010 +0100

    Add comment about CMP0017 to docs of include()
    
    Alex

diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h
index 8704750..a6d43ba 100644
--- a/Source/cmIncludeCommand.h
+++ b/Source/cmIncludeCommand.h
@@ -73,7 +73,12 @@ public:
       "the variable will be set to the full filename which "
       "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."
+      "<modulename>.cmake is searched first in CMAKE_MODULE_PATH, then in the "
+      "CMake module directory. There is one exception to this: if the file "
+      "which calls include() is located itself in the CMake module directory, "
+      "then first the CMake module directory is searched and "
+      "CMAKE_MODULE_PATH afterwards. This behaviour is controlled by policy "
+      "CMP0017."
       "\n"
       "See the cmake_policy() command documentation for discussion of the "
       "NO_POLICY_SCOPE option."

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e8559879e983bd5857f521a4b3274eea6387ccd
commit 3e8559879e983bd5857f521a4b3274eea6387ccd
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Dec 14 22:25:53 2010 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Dec 14 22:25:53 2010 +0100

    Remove trailing whitespace
    
    Alex

diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h
index a215275..8704750 100644
--- a/Source/cmIncludeCommand.h
+++ b/Source/cmIncludeCommand.h
@@ -15,7 +15,7 @@
 #include "cmCommand.h"
 
 /** \class cmIncludeCommand
- * \brief 
+ * \brief
  *
  *  cmIncludeCommand defines a list of distant
  *  files that can be "included" in the current list file.
@@ -28,7 +28,7 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone() 
+  virtual cmCommand* Clone()
     {
     return new cmIncludeCommand;
     }
@@ -49,15 +49,15 @@ public:
    * The name of the command as specified in CMakeList.txt.
    */
   virtual const char* GetName() {return "include";}
-  
+
   /**
    * Succinct documentation.
    */
-  virtual const char* GetTerseDocumentation() 
+  virtual const char* GetTerseDocumentation()
     {
     return "Read CMake listfile code from the given file.";
     }
-  
+
   /**
    * More documentation.
    */
@@ -79,7 +79,7 @@ public:
       "NO_POLICY_SCOPE option."
       ;
     }
-  
+
   cmTypeMacro(cmIncludeCommand, cmCommand);
 };
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=364530c94ec1f81f21fda6771a23670fe7e0a6bb
commit 364530c94ec1f81f21fda6771a23670fe7e0a6bb
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Dec 14 22:25:21 2010 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Dec 14 22:25:21 2010 +0100

    Remove trailing whitespace
    
    Alex

diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index c9b14a1..0ac6df4 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -26,10 +26,10 @@ bool cmIncludeCommand
   bool noPolicyScope = false;
   std::string fname = args[0];
   std::string resultVarName;
-  
+
   for (unsigned int i=1; i<args.size(); i++)
     {
-    if (args[i] == "OPTIONAL") 
+    if (args[i] == "OPTIONAL")
       {
       if (optional)
         {
@@ -60,10 +60,10 @@ bool cmIncludeCommand
       {
       noPolicyScope = true;
       }
-      else if(i > 1)  // compat.: in previous cmake versions the second 
+      else if(i > 1)  // compat.: in previous cmake versions the second
                       // parameter was ignore if it wasn't "OPTIONAL"
         {
-        std::string errorText = "called with invalid argument: ";  
+        std::string errorText = "called with invalid argument: ";
         errorText += args[i];
         this->SetError(errorText.c_str());
         return false;
@@ -82,15 +82,15 @@ bool cmIncludeCommand
       }
     }
   std::string fullFilePath;
-  bool readit = 
-    this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), 
+  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
   if (resultVarName.size())
     {
-      this->Makefile->AddDefinition(resultVarName.c_str(), 
+      this->Makefile->AddDefinition(resultVarName.c_str(),
                                     readit?fullFilePath.c_str():"NOTFOUND");
     }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eb74f519e90d880ed895ea2243aae2d64c2ba8f4
commit eb74f519e90d880ed895ea2243aae2d64c2ba8f4
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 23 22:19:47 2010 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Nov 23 22:19:47 2010 +0100

    Add support for CMAKE_POLICY_DEFAULT_CMP<NNNN> variables.
    
    If cmake finds a cmake_minimum_required(VERSION x.y.z) call, it
    sets all now existing policies which did not yet exist in version x.y.z
    to WARN. In some cases (KDE and FPHSA mess-up, maybe cygwin and
    defining WIN32) it may be necessary to switch such a new policy to
    NEW. This can be done now with this patch by specifying a
    CMAKE_POLICY_DEFAULT_CMP<NNNN>, which can be either set to NEW or OLD
    and nothing else, as suggested by Brad.
    
    TODO: docs and test
    
    Alex

diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 1183ba1..692ef69 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -581,9 +581,44 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
         {
         ancientPolicies.push_back(i->first);
         }
-      else if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN))
+      else
         {
-        return false;
+        // By default, all policies which did not exist in older cmake versions
+        // will be set to WARN. This can be overridden using
+        // CMAKE_POLICY_DEFAULT_CMP<NNNN> variables. In some case this is
+        // necessary to keep old projects building.
+        cmPolicies::PolicyStatus policyStatus = cmPolicies::WARN;
+
+        std::string defaultPolicySettingVar = "CMAKE_POLICY_DEFAULT_";
+        defaultPolicySettingVar += i->second->IDString;
+        std::string defaultPolicySetting = mf->GetSafeDefinition(
+                                              defaultPolicySettingVar.c_str());
+
+        if (defaultPolicySetting.size() > 0)
+          {
+          if (defaultPolicySetting == "NEW")
+            {
+            policyStatus = cmPolicies::NEW;
+            }
+          else if (defaultPolicySetting == "OLD")
+            {
+            policyStatus = cmPolicies::OLD;
+            }
+          else
+            {
+            cmOStringStream e;
+            e << "Requested to set policy " << i->second->IDString << " to "
+              << defaultPolicySetting << ", but only NEW and OLD can be used."
+              <<  "\n";
+            mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+            return false;
+            }
+          }
+
+        if (!mf->SetPolicy(i->second->ID, policyStatus))
+          {
+          return false;
+          }
         }
       }
     else

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15712e2be89983e6be8a3d4b3a20966163266c00
commit 15712e2be89983e6be8a3d4b3a20966163266c00
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 23 21:53:35 2010 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Nov 23 21:53:35 2010 +0100

    Fix indentation in cmPolicies::ApplyPolicyVersion()
    
    Alex

diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 8e9ac6d..1183ba1 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -511,9 +511,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;
@@ -572,29 +572,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())

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=07410f329d8a219fc8c6153212cdcdb6034ab27c
commit 07410f329d8a219fc8c6153212cdcdb6034ab27c
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Wed Nov 17 22:32:53 2010 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Wed Nov 17 22:32:53 2010 +0100

    Prefer files from CMAKE_ROOT when including from CMAKE_ROOT.
    
    This patch makes include() and find_package() prefer cmake files
    located in CMAKE_ROOT over those in CMAKE_MODULE_PATH.
    This makes sure that the including file gets that file included
    which it expects, i.e. the one from cmake with which it was tested.
    It only changes behaviour when such an included file exists both
    in CMAKE_MODULE_PATH and in CMAKE_ROOT.
    This comes together with a new policy CMP0017, with default
    behaviour it behaves as it always did, but warns.
    With NEW behaviour it includes the file from CMAKE_ROOT
    instead from CMAKE_MODULE_PATH. This fixes (if CMP0017 is set)
    building KDE 4.5 with cmake >= 2.8.3.
    Also a basic test for this policy in included.
    
    Alex

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 56e0ed9..ccf4d7a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2822,35 +2822,100 @@ void cmMakefile::DisplayStatus(const char* message, float s)
 
 std::string cmMakefile::GetModulesFile(const char* filename)
 {
-  std::vector<std::string> modulePath;
-  const char* def = this->GetDefinition("CMAKE_MODULE_PATH");
-  if(def)
+  std::string result;
+
+  // We search the module always in CMAKE_ROOT and in CMAKE_MODULE_PATH,
+  // and then decide based on the policy setting which one to return.
+  // See CMP0017 for more details.
+  // The specific problem was that KDE 4.5.0 installs a
+  // FindPackageHandleStandardArgs.cmake which doesn't have the new features
+  // of FPHSA.cmake introduced in CMake 2.8.3 yet, and by setting
+  // CMAKE_MODULE_PATH also e.g. FindZLIB.cmake from cmake included
+  // FPHSA.cmake from kdelibs and not from CMake, and tried to use the
+  // new features, which were not there in the version from kdelibs, and so
+  // failed ("
+  std::string moduleInCMakeRoot;
+  std::string moduleInCMakeModulePath;
+
+  // Always search in CMAKE_MODULE_PATH:
+  const char* cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH");
+  if(cmakeModulePath)
+    {
+    std::vector<std::string> modulePath;
+    cmSystemTools::ExpandListArgument(cmakeModulePath, modulePath);
+
+    //Look through the possible module directories.
+    for(std::vector<std::string>::iterator i = modulePath.begin();
+        i != modulePath.end(); ++i)
+      {
+      std::string itempl = *i;
+      cmSystemTools::ConvertToUnixSlashes(itempl);
+      itempl += "/";
+      itempl += filename;
+      if(cmSystemTools::FileExists(itempl.c_str()))
+        {
+        moduleInCMakeModulePath = itempl;
+        break;
+        }
+      }
+    }
+
+  // Always search in the standard modules location.
+  const char* cmakeRoot = this->GetDefinition("CMAKE_ROOT");
+  if(cmakeRoot)
     {
-    cmSystemTools::ExpandListArgument(def, modulePath);
+    moduleInCMakeRoot = cmakeRoot;
+    moduleInCMakeRoot += "/Modules/";
+    moduleInCMakeRoot += filename;
+    cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
+    if(!cmSystemTools::FileExists(moduleInCMakeRoot.c_str()))
+      {
+      moduleInCMakeRoot = "";
+      }
     }
 
-  // Also search in the standard modules location.
-  def = this->GetDefinition("CMAKE_ROOT");
-  if(def)
+  // Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
+  // from which we are being called is located itself in CMAKE_ROOT, then
+  // prefer results from CMAKE_ROOT depending on the policy setting.
+  result = moduleInCMakeModulePath;
+  if (result.size() == 0)
     {
-    std::string rootModules = def;
-    rootModules += "/Modules";
-    modulePath.push_back(rootModules);
+    result = moduleInCMakeRoot;
     }
-  //std::string  Look through the possible module directories.
-  for(std::vector<std::string>::iterator i = modulePath.begin();
-      i != modulePath.end(); ++i)
+
+  if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0))
     {
-    std::string itempl = *i;
-    cmSystemTools::ConvertToUnixSlashes(itempl);
-    itempl += "/";
-    itempl += filename;
-    if(cmSystemTools::FileExists(itempl.c_str()))
+    const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
+    if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile))
       {
-      return itempl;
+      switch (this->GetPolicyStatus(cmPolicies::CMP0017))
+        {
+        case cmPolicies::WARN:
+        {
+          cmOStringStream e;
+          e << "File " << currentFile << " includes "
+            << moduleInCMakeModulePath
+            << " (found via CMAKE_MODULE_PATH) which shadows "
+            << moduleInCMakeRoot  << ". This may cause errors later on .\n"
+            << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0017);
+
+          this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+           // break;  // fall through to OLD behaviour
+        }
+        case cmPolicies::OLD:
+          result = moduleInCMakeModulePath;
+          break;
+        case cmPolicies::REQUIRED_IF_USED:
+        case cmPolicies::REQUIRED_ALWAYS:
+        case cmPolicies::NEW:
+        default:
+          result = moduleInCMakeRoot;
+          break;
+        }
       }
     }
-  return "";
+
+  return result;
 }
 
 void cmMakefile::ConfigureString(const std::string& input,
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 3fe92de..8e9ac6d 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -446,6 +446,22 @@ cmPolicies::cmPolicies()
     "wasn't a valid target. "
     "In CMake 2.8.3 and above it reports an error in this case.",
     2,8,3,0, cmPolicies::WARN);
+
+    this->DefinePolicy(
+    CMP0017, "CMP0017",
+    "Prefer files from CMAKE_ROOT/ when including from CMAKE_ROOT.",
+    "Starting with CMake 2.8.3, if a cmake-module shipped with CMake (i.e. "
+    "located in CMAKE_ROOT/Modules/) calls include() or find_package(), "
+    "the files located in CMAKE_ROOT/Modules/ are prefered over the files "
+    "in CMAKE_MODULE_PATH.  This makes sure that the modules belonging to "
+    "CMake always get those files included which they expect, and against "
+    "which they were developed and tested.  "
+    "In call other cases, the files found in "
+    "CMAKE_MODULE_PATH still take precedence over the ones in "
+    "CMAKE_ROOT/Modules/.  "
+    "The OLD behaviour is to always prefer files from CMAKE_MODULE_PATH over "
+    "files from CMAKE_ROOT/Modules/.",
+    2,8,3,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index fce33ac..2bb16a2 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -52,6 +52,7 @@ public:
     CMP0014, // Input directories must have CMakeLists.txt
     CMP0015, // link_directories() treats paths relative to source dir
     CMP0016, // target_link_libraries() fails if only argument is not a target
+    CMP0017, // Prefer files in CMAKE_ROOT when including from CMAKE_ROOT
 
     // Always the last entry.  Useful mostly to avoid adding a comma
     // the last policy when adding a new one.
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index a472bea..fb12121 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -1,6 +1,15 @@
 cmake_minimum_required (VERSION 2.6)
 PROJECT(FindPackageTest)
 
+LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+# Look for a package which uses FindPackageHandleStandardArgs.cmake with the
+# new (as of cmake 2.8.3) syntax. This works only if CMP0017 is set to NEW,
+# because otherwise FindPackageHandleStandardArgs.cmake from the current
+# directory is included (via CMAKE_MODULE_PATH).
+CMAKE_POLICY(SET CMP0017 NEW)
+FIND_PACKAGE(ZLIB)
+
 # Look for a package that has a find module and may be found.
 FIND_PACKAGE(OpenGL QUIET)
 
@@ -23,7 +32,6 @@ IF(NOT FOO_DIR)
   CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
 ENDIF(NOT FOO_DIR)
 
-LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
 FIND_PACKAGE(VersionTestA 1)
 FIND_PACKAGE(VersionTestB 1.2)
 FIND_PACKAGE(VersionTestC 1.2.3)
diff --git a/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake b/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake
new file mode 100644
index 0000000..7e41c96
--- /dev/null
+++ b/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This file (${CMAKE_CURRENT_LIST_FILE}) must not be included, but FindPackageHandleStandardArgs.cmake from Modules/ instead !")

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

Summary of changes:
 Source/cmIncludeCommand.cxx                        |   16 ++--
 Source/cmIncludeCommand.h                          |   19 +++--
 Source/cmMakefile.cxx                              |  105 ++++++++++++++++----
 Source/cmPolicies.cxx                              |   82 ++++++++++++---
 Source/cmPolicies.h                                |    1 +
 Tests/FindPackageTest/CMakeLists.txt               |   10 ++-
 .../FindPackageHandleStandardArgs.cmake            |    1 +
 7 files changed, 182 insertions(+), 52 deletions(-)
 create mode 100644 Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list