[Cmake-commits] CMake branch, next, updated. v2.8.2-589-ge6381e8

Alexander Neundorf neundorf at kde.org
Sun Aug 29 12:14:16 EDT 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  e6381e8a68fe70d71e5f581e4a1a8fcf37190246 (commit)
       via  0367245f0c1a665d44b7169cc0f24eda5dbb4de3 (commit)
       via  130b0e21958535a4f4f408cf7392fa9b3ee336fe (commit)
       via  dfe9c95129b9ca05ea8ca98e69d973c9c40e5a4e (commit)
      from  4ead6713c4a0aa0f04a6895ed8cc0c8bee52cc07 (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=e6381e8a68fe70d71e5f581e4a1a8fcf37190246
commit e6381e8a68fe70d71e5f581e4a1a8fcf37190246
Merge: 4ead671 0367245
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Aug 29 18:12:22 2010 +0200
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Aug 29 18:12:22 2010 +0200

    Merge branch 'ImproveFindPackageConfigMode' into next


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0367245f0c1a665d44b7169cc0f24eda5dbb4de3
commit 0367245f0c1a665d44b7169cc0f24eda5dbb4de3
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Aug 29 17:51:44 2010 +0200
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Aug 29 17:51:44 2010 +0200

    Replace the two vector<string,string> with one vector<struct{string,string}>
    
    Before this patch there were two separate vectors, and the code made sure
    they always had the same size.
    With this patch the code doesn't have to ensure this anymore, there is only
    one vector now.
    
    Alex

diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 90fcf69..48122a8 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -726,8 +726,7 @@ bool cmFindPackageCommand::FindModule(bool& found)
 //----------------------------------------------------------------------------
 bool cmFindPackageCommand::HandlePackageMode()
 {
-  this->ConsideredConfigFiles.clear();
-  this->ConsideredVersions.clear();
+  this->ConsideredConfigs.clear();
 
   // Support old capitalization behavior.
   std::string upperDir = cmSystemTools::UpperCase(this->Name);
@@ -819,17 +818,17 @@ bool cmFindPackageCommand::HandlePackageMode()
     cmOStringStream e;
     // If there are files in ConsideredConfigs, it means that FooConfig.cmake
     // have been found, but they didn't have appropriate versions.
-    if (this->ConsideredConfigFiles.size() > 0)
+    if (this->ConsideredConfigs.size() > 0)
       {
       e << "Could not find configuration file for package " << this->Name
         << " with " << (this->VersionExact ? "exact " : "at least ")
         << "version " << this->Version << " .\n"
         << "Found the following files:\n";
-      for(std::vector<std::string>::size_type i=0;
-          i<this->ConsideredConfigFiles.size(); i++)
+      for(std::vector<ConfigFileInfo>::size_type i=0;
+          i<this->ConsideredConfigs.size(); i++)
         {
-        e << "  " << this->ConsideredConfigFiles[i]
-          << ", version: " << this->ConsideredVersions[i] << "\n";
+        e << "  " << this->ConsideredConfigs[i].filename
+          << ", version: " << this->ConsideredConfigs[i].version << "\n";
         }
       }
     else
@@ -933,12 +932,12 @@ bool cmFindPackageCommand::HandlePackageMode()
   std::string consideredConfigFiles;
   std::string consideredVersions;
 
-  for(std::vector<std::string>::size_type i=0;
-      i<this->ConsideredConfigFiles.size(); i++)
+  for(std::vector<ConfigFileInfo>::size_type i=0;
+      i<this->ConsideredConfigs.size(); i++)
     {
-    consideredConfigFiles += this->ConsideredConfigFiles[i];
+    consideredConfigFiles += this->ConsideredConfigs[i].filename;
     consideredConfigFiles += ";";
-    consideredVersions += this->ConsideredVersions[i];
+    consideredVersions += this->ConsideredConfigs[i].version;
     consideredVersions += ";";
     }
 
@@ -1554,8 +1553,10 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
     haveResult = true;
     }
 
-  this->ConsideredConfigFiles.push_back(config_file);
-  this->ConsideredVersions.push_back(version);
+  ConfigFileInfo configFileInfo;
+  configFileInfo.filename = config_file;
+  configFileInfo.version = version;
+  this->ConsideredConfigs.push_back(configFileInfo);
 
   return result;
 }
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 2495d6c..57aeab9 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -138,8 +138,9 @@ private:
   std::vector<std::string> Names;
   std::vector<std::string> Configs;
   std::set<std::string> IgnoredPaths;
-  std::vector<std::string> ConsideredConfigFiles;
-  std::vector<std::string> ConsideredVersions;
+
+  struct ConfigFileInfo { std::string filename; std::string version; };
+  std::vector<ConfigFileInfo> ConsideredConfigs;
 };
 
 #endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=130b0e21958535a4f4f408cf7392fa9b3ee336fe
commit 130b0e21958535a4f4f408cf7392fa9b3ee336fe
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Aug 29 17:43:45 2010 +0200
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Aug 29 17:43:45 2010 +0200

    Improve error message in Config-mode when no appropriate version was found
    
    If in config-mode config files have been found by find_package(), but their
    version didn't match the requested version, now all considered files
    and their versions are printed (instead of saying "didn't find config file)
    
    Alex

diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index b8dcb3d..90fcf69 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -817,36 +817,56 @@ bool cmFindPackageCommand::HandlePackageMode()
     {
     // The variable is not set.
     cmOStringStream e;
-    e << "Could not find ";
-    if(!this->NoModule)
-      {
-      e << "module Find" << this->Name << ".cmake or ";
-      }
-    e << "a configuration file for package " << this->Name << ".\n";
-    if(!this->NoModule)
-      {
-      e << "Adjust CMAKE_MODULE_PATH to find Find"
-        << this->Name << ".cmake or set ";
-      }
-    else
-      {
-      e << "Set ";
-      }
-    e << this->Variable << " to the directory containing a CMake "
-      << "configuration file for " << this->Name << ".  ";
-    if(this->Configs.size() == 1)
-      {
-      e << "The file will be called " << this->Configs[0];
+    // If there are files in ConsideredConfigs, it means that FooConfig.cmake
+    // have been found, but they didn't have appropriate versions.
+    if (this->ConsideredConfigFiles.size() > 0)
+      {
+      e << "Could not find configuration file for package " << this->Name
+        << " with " << (this->VersionExact ? "exact " : "at least ")
+        << "version " << this->Version << " .\n"
+        << "Found the following files:\n";
+      for(std::vector<std::string>::size_type i=0;
+          i<this->ConsideredConfigFiles.size(); i++)
+        {
+        e << "  " << this->ConsideredConfigFiles[i]
+          << ", version: " << this->ConsideredVersions[i] << "\n";
+        }
       }
     else
       {
-      e << "The file will have one of the following names:\n";
-      for(std::vector<std::string>::const_iterator ci = this->Configs.begin();
-          ci != this->Configs.end(); ++ci)
+      e << "Could not find ";
+      if(!this->NoModule)
+        {
+        e << "module Find" << this->Name << ".cmake or ";
+        }
+      e << "a configuration file for package " << this->Name << ".\n";
+      if(!this->NoModule)
+        {
+        e << "Adjust CMAKE_MODULE_PATH to find Find"
+          << this->Name << ".cmake or set ";
+        }
+      else
+        {
+        e << "Set ";
+        }
+      e << this->Variable << " to the directory containing a CMake "
+        << "configuration file for " << this->Name << ".  ";
+      if(this->Configs.size() == 1)
+        {
+        e << "The file will be called " << this->Configs[0];
+        }
+      else
         {
-        e << "  " << *ci << "\n";
+        e << "The file will have one of the following names:\n";
+        for(std::vector<std::string>::const_iterator ci=this->Configs.begin();
+            ci != this->Configs.end(); ++ci)
+          {
+          e << "  " << *ci << "\n";
+          }
         }
       }
+
+
     this->Makefile->IssueMessage(
       this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str());
     }
@@ -911,20 +931,14 @@ bool cmFindPackageCommand::HandlePackageMode()
   consideredVersionsVar += "_CONSIDERED_VERSIONS";
 
   std::string consideredConfigFiles;
-  for(std::vector<std::string>::const_iterator
-      it = this->ConsideredConfigFiles.begin();
-      it != this->ConsideredConfigFiles.end(); ++it)
-    {
-    consideredConfigFiles += *it;
-    consideredConfigFiles += ";";
-    }
-
   std::string consideredVersions;
-  for(std::vector<std::string>::const_iterator
-      it = this->ConsideredVersions.begin();
-      it != this->ConsideredVersions.end(); ++it)
+
+  for(std::vector<std::string>::size_type i=0;
+      i<this->ConsideredConfigFiles.size(); i++)
     {
-    consideredVersions += *it;
+    consideredConfigFiles += this->ConsideredConfigFiles[i];
+    consideredConfigFiles += ";";
+    consideredVersions += this->ConsideredVersions[i];
     consideredVersions += ";";
     }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dfe9c95129b9ca05ea8ca98e69d973c9c40e5a4e
commit dfe9c95129b9ca05ea8ca98e69d973c9c40e5a4e
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Sun Aug 29 17:07:39 2010 +0200
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Sun Aug 29 17:07:39 2010 +0200

    Record all considered Config files and their versions.
    
    As suggested on cmake-devel, find_package in Config-mode now records
    all considered config-files and their versions in
    <package>_CONSIDERED_CONFIGS and <package>_CONSIDERED_VERSIONS respectively.
    
    Alex

diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index eb86014..b8dcb3d 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -156,6 +156,11 @@ cmFindPackageCommand::cmFindPackageCommand()
     "The full path to the configuration file is stored in the cmake "
     "variable <package>_CONFIG."
     "\n"
+    "All configuration files which have been considered by CMake while "
+    "searching for an installation of the package with an appropriate "
+    "version are stored in the cmake variable <package>_CONSIDERED_CONFIGS, "
+    "the associated versions in <package>_CONSIDERED_VERSIONS. "
+    "\n"
     "If the package configuration file cannot be found CMake "
     "will generate an error describing the problem unless the QUIET "
     "argument is specified.  If REQUIRED is specified and the package "
@@ -618,7 +623,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
   // Store the list of components.
   std::string components_var = this->Name + "_FIND_COMPONENTS";
   this->AddFindDefinition(components_var.c_str(), components.c_str());
-   
+
   if(this->Quiet)
     {
     // Tell the module that is about to be read that it should find
@@ -721,6 +726,9 @@ bool cmFindPackageCommand::FindModule(bool& found)
 //----------------------------------------------------------------------------
 bool cmFindPackageCommand::HandlePackageMode()
 {
+  this->ConsideredConfigFiles.clear();
+  this->ConsideredVersions.clear();
+
   // Support old capitalization behavior.
   std::string upperDir = cmSystemTools::UpperCase(this->Name);
   std::string upperFound = cmSystemTools::UpperCase(this->Name);
@@ -897,6 +905,35 @@ bool cmFindPackageCommand::HandlePackageMode()
     }
 #endif
 
+  std::string consideredConfigsVar = this->Name;
+  consideredConfigsVar += "_CONSIDERED_CONFIGS";
+  std::string consideredVersionsVar = this->Name;
+  consideredVersionsVar += "_CONSIDERED_VERSIONS";
+
+  std::string consideredConfigFiles;
+  for(std::vector<std::string>::const_iterator
+      it = this->ConsideredConfigFiles.begin();
+      it != this->ConsideredConfigFiles.end(); ++it)
+    {
+    consideredConfigFiles += *it;
+    consideredConfigFiles += ";";
+    }
+
+  std::string consideredVersions;
+  for(std::vector<std::string>::const_iterator
+      it = this->ConsideredVersions.begin();
+      it != this->ConsideredVersions.end(); ++it)
+    {
+    consideredVersions += *it;
+    consideredVersions += ";";
+    }
+
+  this->Makefile->AddDefinition(consideredConfigsVar.c_str(),
+                                consideredConfigFiles.c_str());
+
+  this->Makefile->AddDefinition(consideredVersionsVar.c_str(),
+                                consideredVersions.c_str());
+
   return result;
 }
 
@@ -1467,6 +1504,10 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
 //----------------------------------------------------------------------------
 bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
 {
+  bool result = false; // by default, assume the version is not ok.
+  bool haveResult = false;
+  std::string version = "unknown";
+
   // Get the filename without the .cmake extension.
   std::string::size_type pos = config_file.rfind('.');
   std::string version_file_base = config_file.substr(0, pos);
@@ -1474,31 +1515,40 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
   // Look for foo-config-version.cmake
   std::string version_file = version_file_base;
   version_file += "-version.cmake";
-  if(cmSystemTools::FileExists(version_file.c_str(), true))
+  if ((haveResult == false)
+       && (cmSystemTools::FileExists(version_file.c_str(), true)))
     {
-    return this->CheckVersionFile(version_file);
+    result = this->CheckVersionFile(version_file, version);
+    haveResult = true;
     }
 
   // Look for fooConfigVersion.cmake
   version_file = version_file_base;
   version_file += "Version.cmake";
-  if(cmSystemTools::FileExists(version_file.c_str(), true))
+  if ((haveResult == false)
+       && (cmSystemTools::FileExists(version_file.c_str(), true)))
     {
-    return this->CheckVersionFile(version_file);
+    result = this->CheckVersionFile(version_file, version);
+    haveResult = true;
     }
 
+
   // If no version was requested a versionless package is acceptable.
-  if(this->Version.empty())
+  if ((haveResult == false) && (this->Version.empty()))
     {
-    return true;
+    result = true;
+    haveResult = true;
     }
 
-  // No version file found.  Assume the version is incompatible.
-  return false;
+  this->ConsideredConfigFiles.push_back(config_file);
+  this->ConsideredVersions.push_back(version);
+
+  return result;
 }
 
 //----------------------------------------------------------------------------
-bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file)
+bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
+                                            std::string& result_version)
 {
   // The version file will be loaded in an isolated scope.
   cmMakefile::ScopePushPop varScope(this->Makefile);
@@ -1571,6 +1621,12 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file)
       }
     }
 
+  result_version = this->Makefile->GetSafeDefinition("PACKAGE_VERSION");
+  if (result_version.empty())
+    {
+    result_version = "unknown";
+    }
+
   // Succeed if the version is suitable.
   return suitable;
 }
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 53ea4fc..2495d6c 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -98,7 +98,8 @@ private:
   bool CheckDirectory(std::string const& dir);
   bool FindConfigFile(std::string const& dir, std::string& file);
   bool CheckVersion(std::string const& config_file);
-  bool CheckVersionFile(std::string const& version_file);
+  bool CheckVersionFile(std::string const& version_file,
+                        std::string& result_version);
   bool SearchPrefix(std::string const& prefix);
   bool SearchFrameworkPrefix(std::string const& prefix_in);
   bool SearchAppBundlePrefix(std::string const& prefix_in);
@@ -137,6 +138,8 @@ private:
   std::vector<std::string> Names;
   std::vector<std::string> Configs;
   std::set<std::string> IgnoredPaths;
+  std::vector<std::string> ConsideredConfigFiles;
+  std::vector<std::string> ConsideredVersions;
 };
 
 #endif

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

Summary of changes:
 Source/cmFindPackageCommand.cxx |  137 +++++++++++++++++++++++++++++---------
 Source/cmFindPackageCommand.h   |    6 ++-
 2 files changed, 109 insertions(+), 34 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list