[Cmake-commits] CMake branch, next, updated. v3.0.2-2163-g531195e

Brad King brad.king at kitware.com
Wed Oct 22 16:55:24 EDT 2014


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  531195e9f309632580e4e694413ca863465a9531 (commit)
       via  1d3c59560e1228cd37d983c02307c0aeebf76801 (commit)
      from  3835aae6986b6e029771e14f785ca207778c70d2 (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=531195e9f309632580e4e694413ca863465a9531
commit 531195e9f309632580e4e694413ca863465a9531
Merge: 3835aae 1d3c595
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Oct 22 16:55:23 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Oct 22 16:55:23 2014 -0400

    Merge topic 'refactor-search-path-construction' into next
    
    1d3c5956 Revert topic 'refactor-search-path-construction'


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d3c59560e1228cd37d983c02307c0aeebf76801
commit 1d3c59560e1228cd37d983c02307c0aeebf76801
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Oct 22 16:52:38 2014 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Oct 22 16:52:38 2014 -0400

    Revert topic 'refactor-search-path-construction'
    
    It will be rebased and restored later.

diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx
index 5502609..9093579 100644
--- a/Source/cmBootstrapCommands1.cxx
+++ b/Source/cmBootstrapCommands1.cxx
@@ -52,8 +52,6 @@
 #include "cmFindProgramCommand.cxx"
 #include "cmForEachCommand.cxx"
 #include "cmFunctionCommand.cxx"
-#include "cmPathLabel.cxx"
-#include "cmSearchPath.cxx"
 
 void GetBootstrapCommands1(std::list<cmCommand*>& commands)
 {
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index beb6dde..e4e819a 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -140,11 +140,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
       }
     else if(doing == DoingPaths)
       {
-      this->UserGuessArgs.push_back(args[j]);
+      this->AddUserPath(args[j], this->UserPaths);
       }
     else if(doing == DoingHints)
       {
-      this->UserHintsArgs.push_back(args[j]);
+      this->AddUserPath(args[j], this->UserHints);
       }
     else if(doing == DoingPathSuffixes)
       {
@@ -186,11 +186,16 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
     this->Names.push_back(shortArgs[0]);
     for(unsigned int j = 1; j < shortArgs.size(); ++j)
       {
-      this->UserGuessArgs.push_back(shortArgs[j]);
+      this->AddUserPath(shortArgs[j], this->UserPaths);
       }
     }
   this->ExpandPaths();
 
+  // Filter out ignored paths from the prefix list
+  std::set<std::string> ignored;
+  this->GetIgnoredPaths(ignored);
+  this->FilterPaths(this->SearchPaths, ignored);
+
   this->ComputeFinalPaths();
 
   return true;
@@ -198,142 +203,226 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
 
 void cmFindBase::ExpandPaths()
 {
-  if(!this->NoDefaultPath)
+  this->AddCMakeVariablePath();
+  this->AddCMakeEnvironmentPath();
+  this->AddUserHintsPath();
+  this->AddSystemEnvironmentPath();
+  this->AddCMakeSystemVariablePath();
+  this->AddUserGuessPath();
+
+  // Add suffixes and clean up paths.
+  this->AddPathSuffixes();
+}
+
+//----------------------------------------------------------------------------
+void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
+                                PathType pathType)
+{
+  // default for programs
+  std::string subdir = "bin";
+
+  if (this->CMakePathName == "INCLUDE")
+    {
+    subdir = "include";
+    }
+  else if (this->CMakePathName == "LIBRARY")
     {
-    if(!this->NoCMakePath)
+    subdir = "lib";
+    }
+  else if (this->CMakePathName == "FRAMEWORK")
+    {
+    subdir = "";  // ? what to do for frameworks ?
+    }
+
+  for(std::vector<std::string>::const_iterator it = in_paths.begin();
+      it != in_paths.end(); ++it)
+    {
+    std::string dir = *it;
+    if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/')
+      {
+      dir += "/";
+      }
+    if(subdir == "include" || subdir == "lib")
       {
-      this->FillCMakeVariablePath();
+      const char* arch =
+        this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE");
+      if(arch && *arch)
+        {
+        this->AddPathInternal(dir+subdir+"/"+arch, pathType);
+        }
       }
-    if(!this->NoCMakeEnvironmentPath)
+    std::string add = dir + subdir;
+    if(add != "/")
       {
-      this->FillCMakeEnvironmentPath();
+      this->AddPathInternal(add, pathType);
       }
-    if(!this->NoSystemEnvironmentPath)
+    if (subdir == "bin")
       {
-      this->FillSystemEnvironmentPath();
+      this->AddPathInternal(dir+"sbin", pathType);
       }
-    if(!this->NoCMakeSystemPath)
+    if(!subdir.empty() && *it != "/")
       {
-      this->FillCMakeSystemVariablePath();
+      this->AddPathInternal(*it, pathType);
       }
     }
-
-  this->FillUserHintsPath();
-  this->FillUserGuessPath();
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::FillCMakeEnvironmentPath()
+void cmFindBase::AddCMakePrefixPath(const std::string& variable)
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
-
-  // Add CMAKE_*_PATH environment variables
-  std::string var = "CMAKE_";
-  var += this->CMakePathName;
-  var += "_PATH";
-  paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH");
-  paths.AddEnvPath(var);
-
-  if(this->CMakePathName == "PROGRAM")
+  // Get a path from a CMake variable.
+  if(const char* varPath = this->Makefile->GetDefinition(variable))
     {
-    paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
+    std::vector<std::string> tmp;
+    cmSystemTools::ExpandListArgument(varPath, tmp);
+    this->AddPrefixPaths(tmp, CMakePath);
     }
-  else
-    {
-    paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
-    }
-  paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::FillCMakeVariablePath()
+void cmFindBase::AddEnvPrefixPath(const std::string& variable)
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake];
-
-  // Add CMake varibles of the same name as the previous environment
-  // varibles CMAKE_*_PATH to be used most of the time with -D
-  // command line options
-  std::string var = "CMAKE_";
-  var += this->CMakePathName;
-  var += "_PATH";
-  paths.AddCMakePrefixPath("CMAKE_PREFIX_PATH");
-  paths.AddCMakePath(var);
-
-  if(this->CMakePathName == "PROGRAM")
-    {
-    paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
-    }
-  else
-    {
-    paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
-    }
-  paths.AddSuffixes(this->SearchPathSuffixes);
+  // Get a path from the environment.
+  std::vector<std::string> tmp;
+  cmSystemTools::GetPath(tmp, variable.c_str());
+  this->AddPrefixPaths(tmp, EnvPath);
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::FillSystemEnvironmentPath()
+void cmFindBase::AddCMakeEnvironmentPath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment];
-
-  // Add LIB or INCLUDE
-  if(!this->EnvironmentPath.empty())
+  if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
     {
-    paths.AddEnvPath(this->EnvironmentPath);
+    // Add CMAKE_*_PATH environment variables
+    std::string var = "CMAKE_";
+    var += this->CMakePathName;
+    var += "_PATH";
+    this->AddEnvPrefixPath("CMAKE_PREFIX_PATH");
+    this->AddEnvPath(var.c_str());
+
+    if(this->CMakePathName == "PROGRAM")
+      {
+      this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
+      }
+    else
+      {
+      this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
+      }
     }
-  // Add PATH
-  paths.AddEnvPath("PATH");
-  paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::FillCMakeSystemVariablePath()
+void cmFindBase::AddCMakeVariablePath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem];
-
-  std::string var = "CMAKE_SYSTEM_";
-  var += this->CMakePathName;
-  var += "_PATH";
-  paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
-  paths.AddCMakePath(var);
-
-  if(this->CMakePathName == "PROGRAM")
+  if(!this->NoCMakePath && !this->NoDefaultPath)
     {
-    paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
+    // Add CMake varibles of the same name as the previous environment
+    // varibles CMAKE_*_PATH to be used most of the time with -D
+    // command line options
+    std::string var = "CMAKE_";
+    var += this->CMakePathName;
+    var += "_PATH";
+    this->AddCMakePrefixPath("CMAKE_PREFIX_PATH");
+    this->AddCMakePath(var);
+
+    if(this->CMakePathName == "PROGRAM")
+      {
+      this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
+      }
+    else
+      {
+      this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
+      }
     }
-  else
+}
+
+//----------------------------------------------------------------------------
+void cmFindBase::AddSystemEnvironmentPath()
+{
+  if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
     {
-    paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
+    // Add LIB or INCLUDE
+    if(!this->EnvironmentPath.empty())
+      {
+      this->AddEnvPath(this->EnvironmentPath.c_str());
+      }
+    // Add PATH
+    this->AddEnvPath(0);
     }
-  paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::FillUserHintsPath()
+void cmFindBase::AddCMakeSystemVariablePath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints];
-
-  for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin();
-      p != this->UserHintsArgs.end(); ++p)
+  if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
     {
-    paths.AddUserPath(*p);
+    std::string var = "CMAKE_SYSTEM_";
+    var += this->CMakePathName;
+    var += "_PATH";
+    this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
+    this->AddCMakePath(var);
+
+    if(this->CMakePathName == "PROGRAM")
+      {
+      this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
+      }
+    else
+      {
+      this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
+      }
     }
-  paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::FillUserGuessPath()
+void cmFindBase::AddUserHintsPath()
+{
+  this->AddPathsInternal(this->UserHints, CMakePath);
+}
+
+//----------------------------------------------------------------------------
+void cmFindBase::AddUserGuessPath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess];
+  this->AddPathsInternal(this->UserPaths, CMakePath);
+}
 
-  for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin();
-      p != this->UserGuessArgs.end(); ++p)
+//----------------------------------------------------------------------------
+void cmFindBase::AddPathSuffixes()
+{
+  std::vector<std::string>& paths = this->SearchPaths;
+  std::vector<std::string> finalPath = paths;
+  std::vector<std::string>::iterator i;
+  // clear the path
+  paths.clear();
+  // convert all paths to unix slashes and add search path suffixes
+  // if there are any
+  for(i = finalPath.begin();
+      i != finalPath.end(); ++i)
     {
-    paths.AddUserPath(*p);
+    cmSystemTools::ConvertToUnixSlashes(*i);
+    // copy each finalPath combined with SearchPathSuffixes
+    // to the SearchPaths ivar
+    for(std::vector<std::string>::iterator j =
+          this->SearchPathSuffixes.begin();
+        j != this->SearchPathSuffixes.end(); ++j)
+      {
+      // if *i is only / then do not add a //
+      // this will get incorrectly considered a network
+      // path on windows and cause huge delays.
+      std::string p = *i;
+      if(p.size() && p[p.size()-1] != '/')
+        {
+        p += std::string("/");
+        }
+      p +=  *j;
+      // add to all paths because the search path may be modified
+      // later with lib being replaced for lib64 which may exist
+      paths.push_back(p);
+      }
+    // now put the path without the path suffixes in the SearchPaths
+    paths.push_back(*i);
     }
-  paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::PrintFindStuff()
 {
   std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
@@ -368,10 +457,9 @@ void cmFindBase::PrintFindStuff()
     }
   std::cerr << "\n";
   std::cerr << "SearchPaths\n";
-  for(std::vector<std::string>::const_iterator i = this->SearchPaths.begin();
-      i != this->SearchPaths.end(); ++i)
+  for(unsigned int i =0; i < this->SearchPaths.size(); ++i)
     {
-    std::cerr << "[" << *i << "]\n";
+    std::cerr << "[" << this->SearchPaths[i] << "]\n";
     }
 }
 
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 8ca311d..42d9bc1 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -34,6 +34,7 @@ public:
 protected:
   void PrintFindStuff();
   void ExpandPaths();
+  void AddPathSuffixes();
 
   // see if the VariableName is already set in the cache,
   // also copy the documentation from the cache to VariableDocumentation
@@ -54,12 +55,18 @@ protected:
   bool AlreadyInCacheWithoutMetaInfo;
 private:
   // Add pieces of the search.
-  void FillCMakeVariablePath();
-  void FillCMakeEnvironmentPath();
-  void FillUserHintsPath();
-  void FillSystemEnvironmentPath();
-  void FillCMakeSystemVariablePath();
-  void FillUserGuessPath();
+  void AddCMakeEnvironmentPath();
+  void AddCMakeVariablePath();
+  void AddSystemEnvironmentPath();
+  void AddCMakeSystemVariablePath();
+  void AddUserHintsPath();
+  void AddUserGuessPath();
+
+  // Helpers.
+  void AddCMakePrefixPath(const std::string& variable);
+  void AddEnvPrefixPath(const std::string& variable);
+  void AddPrefixPaths(std::vector<std::string> const& in_paths,
+                      PathType pathType);
 };
 
 
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 913985f..6376d42 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -10,19 +10,6 @@
   See the License for more information.
 ============================================================================*/
 #include "cmFindCommon.h"
-#include <functional>
-#include <algorithm>
-
-//----------------------------------------------------------------------------
-cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
-cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE");
-cmFindCommon::PathLabel
-  cmFindCommon::PathLabel::CMakeEnvironment("CMAKE_ENVIRONMENT");
-cmFindCommon::PathLabel cmFindCommon::PathLabel::Hints("HINTS");
-cmFindCommon::PathLabel
-  cmFindCommon::PathLabel::SystemEnvironment("SYSTM_ENVIRONMENT");
-cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM");
-cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS");
 
 //----------------------------------------------------------------------------
 cmFindCommon::cmFindCommon()
@@ -47,8 +34,6 @@ cmFindCommon::cmFindCommon()
   this->SearchFrameworkLast = false;
   this->SearchAppBundleOnly = false;
   this->SearchAppBundleLast = false;
-
-  this->InitializeSearchPathGroups();
 }
 
 //----------------------------------------------------------------------------
@@ -57,42 +42,11 @@ cmFindCommon::~cmFindCommon()
 }
 
 //----------------------------------------------------------------------------
-void cmFindCommon::InitializeSearchPathGroups()
-{
-  std::vector<PathLabel>* labels;
-
-  // Define the varoius different groups of path types
-
-  // All search paths
-  labels = &this->PathGroupLabelMap[PathGroup::All];
-  labels->push_back(PathLabel::CMake);
-  labels->push_back(PathLabel::CMakeEnvironment);
-  labels->push_back(PathLabel::Hints);
-  labels->push_back(PathLabel::SystemEnvironment);
-  labels->push_back(PathLabel::CMakeSystem);
-  labels->push_back(PathLabel::Guess);
-
-  // Define the search group order
-  this->PathGroupOrder.push_back(PathGroup::All);
-
-  // Create the idividual labeld search paths
-  this->LabeledPaths.insert(std::make_pair(PathLabel::CMake,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeEnvironment,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::Hints,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::SystemEnvironment,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeSystem,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::Guess,
-    cmSearchPath(this)));
-}
-
-//----------------------------------------------------------------------------
 void cmFindCommon::SelectDefaultRootPathMode()
 {
+  // Use both by default.
+  this->FindRootPathMode = RootPathModeBoth;
+
   // Check the policy variable for this find command type.
   std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
   findRootPathVar += this->CMakePathName;
@@ -100,11 +54,11 @@ void cmFindCommon::SelectDefaultRootPathMode()
     this->Makefile->GetSafeDefinition(findRootPathVar);
   if (rootPathMode=="NEVER")
     {
-    this->FindRootPathMode = RootPathModeNever;
+    this->FindRootPathMode = RootPathModeNoRootPath;
     }
   else if (rootPathMode=="ONLY")
     {
-    this->FindRootPathMode = RootPathModeOnly;
+    this->FindRootPathMode = RootPathModeOnlyRootPath;
     }
   else if (rootPathMode=="BOTH")
     {
@@ -178,12 +132,12 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
     fprintf(stderr, "[%s]\n", i->c_str());
     }
 #endif
+
   // Short-circuit if there is nothing to do.
-  if(this->FindRootPathMode == RootPathModeNever)
+  if(this->FindRootPathMode == RootPathModeNoRootPath)
     {
     return;
     }
-
   const char* sysroot =
     this->Makefile->GetDefinition("CMAKE_SYSROOT");
   const char* rootPath =
@@ -258,20 +212,24 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
 }
 
 //----------------------------------------------------------------------------
-void cmFindCommon::FilterPaths(const std::vector<std::string>& inPaths,
-                               const std::set<std::string>& ignore,
-                               std::vector<std::string>& outPaths)
+void cmFindCommon::FilterPaths(std::vector<std::string>& paths,
+                               const std::set<std::string>& ignore)
 {
-  for(std::vector<std::string>::const_iterator i = inPaths.begin();
-      i != inPaths.end(); ++i)
+  // Now filter out anything that's in the ignore set.
+  std::vector<std::string> unfiltered;
+  unfiltered.swap(paths);
+
+  for(std::vector<std::string>::iterator pi = unfiltered.begin();
+      pi != unfiltered.end(); ++pi)
     {
-    if(ignore.count(*i) == 0)
+    if (ignore.count(*pi) == 0)
       {
-      outPaths.push_back(*i);
+      paths.push_back(*pi);
       }
     }
 }
 
+
 //----------------------------------------------------------------------------
 void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore)
 {
@@ -308,6 +266,8 @@ void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore)
   ignore.insert(ignoreVec.begin(), ignoreVec.end());
 }
 
+
+
 //----------------------------------------------------------------------------
 bool cmFindCommon::CheckCommonArgument(std::string const& arg)
 {
@@ -331,13 +291,13 @@ bool cmFindCommon::CheckCommonArgument(std::string const& arg)
     {
     this->NoCMakeSystemPath = true;
     }
-    else if(arg == "NO_CMAKE_FIND_ROOT_PATH")
+  else if(arg == "NO_CMAKE_FIND_ROOT_PATH")
     {
-    this->FindRootPathMode = RootPathModeNever;
+    this->FindRootPathMode = RootPathModeNoRootPath;
     }
   else if(arg == "ONLY_CMAKE_FIND_ROOT_PATH")
     {
-    this->FindRootPathMode = RootPathModeOnly;
+    this->FindRootPathMode = RootPathModeOnlyRootPath;
     }
   else if(arg == "CMAKE_FIND_ROOT_PATH_BOTH")
     {
@@ -385,34 +345,116 @@ void cmFindCommon::AddPathSuffix(std::string const& arg)
 }
 
 //----------------------------------------------------------------------------
-void AddTrailingSlash(std::string& s)
+void cmFindCommon::AddUserPath(std::string const& p,
+                               std::vector<std::string>& paths)
 {
-  if(!s.empty() && *s.rbegin() != '/')
+  // We should view the registry as the target application would view
+  // it.
+  cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
+  cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
+  if(this->Makefile->PlatformIs64Bit())
     {
-    s += '/';
+    view = cmSystemTools::KeyWOW64_64;
+    other_view = cmSystemTools::KeyWOW64_32;
+    }
+
+  // Expand using the view of the target application.
+  std::string expanded = p;
+  cmSystemTools::ExpandRegistryValues(expanded, view);
+  cmSystemTools::GlobDirs(expanded, paths);
+
+  // Executables can be either 32-bit or 64-bit, so expand using the
+  // alternative view.
+  if(expanded != p && this->CMakePathName == "PROGRAM")
+    {
+    expanded = p;
+    cmSystemTools::ExpandRegistryValues(expanded, other_view);
+    cmSystemTools::GlobDirs(expanded, paths);
     }
 }
-void cmFindCommon::ComputeFinalPaths()
+
+//----------------------------------------------------------------------------
+void cmFindCommon::AddCMakePath(const std::string& variable)
+{
+  // Get a path from a CMake variable.
+  if(const char* varPath = this->Makefile->GetDefinition(variable))
+    {
+    std::vector<std::string> tmp;
+    cmSystemTools::ExpandListArgument(varPath, tmp);
+
+    // Relative paths are interpreted with respect to the current
+    // source directory.
+    this->AddPathsInternal(tmp, CMakePath);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFindCommon::AddEnvPath(const char* variable)
+{
+  // Get a path from the environment.
+  std::vector<std::string> tmp;
+  cmSystemTools::GetPath(tmp, variable);
+  // Relative paths are interpreted with respect to the current
+  // working directory.
+  this->AddPathsInternal(tmp, EnvPath);
+}
+
+//----------------------------------------------------------------------------
+void cmFindCommon::AddPathsInternal(std::vector<std::string> const& in_paths,
+                                    PathType pathType)
+{
+  for(std::vector<std::string>::const_iterator i = in_paths.begin();
+      i != in_paths.end(); ++i)
+    {
+    this->AddPathInternal(*i, pathType);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFindCommon::AddPathInternal(std::string const& in_path,
+                                   PathType pathType)
 {
-  // Filter out ignored paths from the prefix list
-  std::set<std::string> ignored;
-  this->GetIgnoredPaths(ignored);
+  if(in_path.empty())
+    {
+    return;
+    }
 
-  // Combine the seperate path types, filtering out ignores
-  this->SearchPaths.clear();
-  std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All];
-  for(std::vector<PathLabel>::const_iterator l = allLabels.begin();
-      l != allLabels.end(); ++l)
+  // Select the base path with which to interpret relative paths.
+  const char* relbase = 0;
+  if(pathType == CMakePath)
     {
-    this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths);
+    relbase = this->Makefile->GetCurrentDirectory();
     }
 
+  // Convert to clean full path.
+  std::string fullPath =
+    cmSystemTools::CollapseFullPath(in_path, relbase);
+
+  // Insert the path if has not already been emitted.
+  if(this->SearchPathsEmitted.insert(fullPath).second)
+    {
+    this->SearchPaths.push_back(fullPath);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmFindCommon::ComputeFinalPaths()
+{
+  std::vector<std::string>& paths = this->SearchPaths;
+
   // Expand list of paths inside all search roots.
-  this->RerootPaths(this->SearchPaths);
+  this->RerootPaths(paths);
 
   // Add a trailing slash to all paths to aid the search process.
-  std::for_each(this->SearchPaths.begin(), this->SearchPaths.end(),
-                &AddTrailingSlash);
+  for(std::vector<std::string>::iterator i = paths.begin();
+      i != paths.end(); ++i)
+    {
+    std::string& p = *i;
+    if(!p.empty() && p[p.size()-1] != '/')
+      {
+      p += "/";
+      }
+    }
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 30d2c3b..5a905cd 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -13,8 +13,6 @@
 #define cmFindCommon_h
 
 #include "cmCommand.h"
-#include "cmSearchPath.h"
-#include "cmPathLabel.h"
 
 /** \class cmFindCommon
  * \brief Base class for FIND_XXX implementations.
@@ -31,39 +29,12 @@ public:
   cmTypeMacro(cmFindCommon, cmCommand);
 
 protected:
-  friend cmSearchPath;
-
-  /** Used to define groups of path labels */
-  class PathGroup : public cmPathLabel
-  {
-  protected:
-    PathGroup();
-  public:
-    PathGroup(const std::string& label) : cmPathLabel(label) { }
-    static PathGroup All;
-  };
-
-  /* Individual path types */
-  class PathLabel : public cmPathLabel
-  {
-  protected:
-    PathLabel();
-  public:
-    PathLabel(const std::string& label) : cmPathLabel(label) { }
-    static PathLabel CMake;
-    static PathLabel CMakeEnvironment;
-    static PathLabel Hints;
-    static PathLabel SystemEnvironment;
-    static PathLabel CMakeSystem;
-    static PathLabel Guess;
-  };
-
-  enum RootPathMode { RootPathModeNever,
-                      RootPathModeOnly,
-                      RootPathModeBoth };
-
-  /** Construct the various path groups and labels */
-  void InitializeSearchPathGroups();
+
+  enum RootPathMode { RootPathModeBoth,
+                      RootPathModeOnlyRootPath,
+                      RootPathModeNoRootPath };
+
+  enum PathType { FullPath, CMakePath, EnvPath };
 
   /** Place a set of search paths under the search roots.  */
   void RerootPaths(std::vector<std::string>& paths);
@@ -73,9 +44,8 @@ protected:
   void GetIgnoredPaths(std::set<std::string>& ignore);
 
   /** Remove paths in the ignore set from the supplied vector.  */
-  void FilterPaths(const std::vector<std::string>& inPaths,
-                   const std::set<std::string>& ignore,
-                   std::vector<std::string>& outPaths);
+  void FilterPaths(std::vector<std::string>& paths,
+                   const std::set<std::string>& ignore);
 
   /** Compute final search path list (reroot + trailing slash).  */
   void ComputeFinalPaths();
@@ -86,15 +56,19 @@ protected:
   /** Compute the current default bundle/framework search policy.  */
   void SelectDefaultMacMode();
 
-  // Path arguments prior to path manipulation routines
-  std::vector<std::string> UserHintsArgs;
-  std::vector<std::string> UserGuessArgs;
-
   std::string CMakePathName;
   RootPathMode FindRootPathMode;
 
   bool CheckCommonArgument(std::string const& arg);
   void AddPathSuffix(std::string const& arg);
+  void AddUserPath(std::string const& p,
+                   std::vector<std::string>& paths);
+  void AddCMakePath(const std::string& variable);
+  void AddEnvPath(const char* variable);
+  void AddPathsInternal(std::vector<std::string> const& in_paths,
+                        PathType pathType);
+  void AddPathInternal(std::string const& in_path, PathType pathType);
+
   void SetMakefile(cmMakefile* makefile);
 
   bool NoDefaultPath;
@@ -104,12 +78,8 @@ protected:
   bool NoCMakeSystemPath;
 
   std::vector<std::string> SearchPathSuffixes;
-
-  std::map<PathGroup, std::vector<PathLabel> > PathGroupLabelMap;
-  std::vector<PathGroup> PathGroupOrder;
-  std::map<std::string, PathLabel> PathLabelStringMap;
-  std::map<PathLabel, cmSearchPath> LabeledPaths;
-
+  std::vector<std::string> UserPaths;
+  std::vector<std::string> UserHints;
   std::vector<std::string> SearchPaths;
   std::set<std::string> SearchPathsEmitted;
 
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 78f0e9e..16deaab 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -88,7 +88,7 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
 {
   std::vector<std::string> original;
   original.swap(this->SearchPaths);
-  for(std::vector<std::string>::const_iterator i = original.begin();
+  for(std::vector<std::string>::iterator i = original.begin();
       i != original.end(); ++i)
     {
     this->AddArchitecturePath(*i, 0, suffix);
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 51f33fd..4633e71 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -26,14 +26,6 @@
 #endif
 
 //----------------------------------------------------------------------------
-cmFindPackageCommand::PathLabel
-  cmFindPackageCommand::PathLabel::UserRegistry("PACKAGE_REGISTRY");
-cmFindPackageCommand::PathLabel
-  cmFindPackageCommand::PathLabel::Builds("BUILDS");
-cmFindPackageCommand::PathLabel
-  cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY");
-
-//----------------------------------------------------------------------------
 cmFindPackageCommand::cmFindPackageCommand()
 {
   this->CMakePathName = "PACKAGE";
@@ -59,33 +51,6 @@ cmFindPackageCommand::cmFindPackageCommand()
   this->VersionFoundTweak = 0;
   this->VersionFoundCount = 0;
   this->RequiredCMakeVersion = 0;
-
-  this->AppendSearchPathGroups();
-}
-
-//----------------------------------------------------------------------------
-void cmFindPackageCommand::AppendSearchPathGroups()
-{
-  std::vector<cmFindCommon::PathLabel>* labels;
-
-  // Update the All group with new paths
-  labels = &this->PathGroupLabelMap[PathGroup::All];
-  labels->insert(std::find(labels->begin(), labels->end(),
-                           PathLabel::CMakeSystem),
-                 PathLabel::UserRegistry);
-  labels->insert(std::find(labels->begin(), labels->end(),
-                           PathLabel::CMakeSystem),
-                 PathLabel::Builds);
-  labels->insert(std::find(labels->begin(), labels->end(), PathLabel::Guess),
-                 PathLabel::SystemRegistry);
-
-  // Create the new path objects
-  this->LabeledPaths.insert(std::make_pair(PathLabel::UserRegistry,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::Builds,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::SystemRegistry,
-    cmSearchPath(this)));
 }
 
 //----------------------------------------------------------------------------
@@ -283,11 +248,11 @@ bool cmFindPackageCommand
       }
     else if(doing == DoingPaths)
       {
-      this->UserGuessArgs.push_back(args[i]);
+      this->AddUserPath(args[i], this->UserPaths);
       }
     else if(doing == DoingHints)
       {
-      this->UserHintsArgs.push_back(args[i]);
+      this->AddUserPath(args[i], this->UserHints);
       }
     else if(doing == DoingPathSuffixes)
       {
@@ -1146,97 +1111,86 @@ void cmFindPackageCommand::AppendSuccessInformation()
 //----------------------------------------------------------------------------
 void cmFindPackageCommand::ComputePrefixes()
 {
-  if(!this->NoDefaultPath)
-    {
-    if(!this->NoCMakePath)
-      {
-      this->FillPrefixesCMakeVariable();
-      }
-    if(!this->NoCMakeEnvironmentPath)
-      {
-      this->FillPrefixesCMakeEnvironment();
-      }
-    if(!this->NoSystemEnvironmentPath)
-      {
-      this->FillPrefixesSystemEnvironment();
-      }
-    if(!this->NoUserRegistry)
-      {
-      this->FillPrefixesUserRegistry();
-      }
-    if(!this->NoBuilds)
-      {
-      this->FillPrefixesBuilds();
-      }
-    if(!this->NoCMakeSystemPath)
-      {
-      this->FillPrefixesCMakeSystemVariable();
-      }
-    if(!this->NoSystemRegistry)
-      {
-      this->FillPrefixesSystemRegistry();
-      }
-    }
-  this->FillPrefixesUserHints();
-  this->FillPrefixesUserGuess();
-
+  this->AddPrefixesCMakeVariable();
+  this->AddPrefixesCMakeEnvironment();
+  this->AddPrefixesUserHints();
+  this->AddPrefixesSystemEnvironment();
+  this->AddPrefixesUserRegistry();
+  this->AddPrefixesBuilds();
+  this->AddPrefixesCMakeSystemVariable();
+  this->AddPrefixesSystemRegistry();
+  this->AddPrefixesUserGuess();
   this->ComputeFinalPaths();
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
+void cmFindPackageCommand::AddPrefixesCMakeEnvironment()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
-
-  // Check the environment variable with the same name as the cache
-  // entry.
-  paths.AddEnvPath(this->Variable);
+  if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
+    {
+    // Check the environment variable with the same name as the cache
+    // entry.
+    std::string env;
+    if(cmSystemTools::GetEnv(this->Variable.c_str(), env) && env.length() > 0)
+      {
+      cmSystemTools::ConvertToUnixSlashes(env);
+      this->AddPathInternal(env, EnvPath);
+      }
 
-  // And now the general CMake environment variables
-  paths.AddEnvPath("CMAKE_PREFIX_PATH");
-  paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
-  paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
+    this->AddEnvPath("CMAKE_PREFIX_PATH");
+    this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
+    this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
+    }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesCMakeVariable()
+void cmFindPackageCommand::AddPrefixesCMakeVariable()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake];
-
-  paths.AddCMakePath("CMAKE_PREFIX_PATH");
-  paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
-  paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
+  if(!this->NoCMakePath && !this->NoDefaultPath)
+    {
+    this->AddCMakePath("CMAKE_PREFIX_PATH");
+    this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
+    this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
+    }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesSystemEnvironment()
+void cmFindPackageCommand::AddPrefixesSystemEnvironment()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment];
-
-  // Use the system search path to generate prefixes.
-  // Relative paths are interpreted with respect to the current
-  // working directory.
-  std::vector<std::string> tmp;
-  cmSystemTools::GetPath(tmp);
-  for(std::vector<std::string>::iterator i = tmp.begin();
-      i != tmp.end(); ++i)
+  if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
     {
-    // If the path is a PREFIX/bin case then add its parent instead.
-    if((cmHasLiteralSuffix(*i, "/bin")) ||
-       (cmHasLiteralSuffix(*i, "/sbin")))
+    // Use the system search path to generate prefixes.
+    // Relative paths are interpreted with respect to the current
+    // working directory.
+    std::vector<std::string> tmp;
+    cmSystemTools::GetPath(tmp);
+    for(std::vector<std::string>::iterator i = tmp.begin();
+        i != tmp.end(); ++i)
       {
-      paths.AddPath(cmSystemTools::GetFilenamePath(*i));
-      }
-    else
-      {
-      paths.AddPath(*i);
+      std::string const& d = *i;
+
+      // If the path is a PREFIX/bin case then add its parent instead.
+      if((cmHasLiteralSuffix(d, "/bin")) ||
+         (cmHasLiteralSuffix(d, "/sbin")))
+        {
+        this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath);
+        }
+      else
+        {
+        this->AddPathInternal(d, EnvPath);
+        }
       }
     }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesUserRegistry()
+void cmFindPackageCommand::AddPrefixesUserRegistry()
 {
+  if(this->NoUserRegistry || this->NoDefaultPath)
+    {
+    return;
+    }
+
 #if defined(_WIN32) && !defined(__CYGWIN__)
   this->LoadPackageRegistryWinUser();
 #elif defined(__HAIKU__)
@@ -1247,8 +1201,7 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
     std::string fname = dir;
     fname += "/cmake/packages/";
     fname += Name;
-    this->LoadPackageRegistryDir(fname,
-                                 this->LabeledPaths[PathLabel::UserRegistry]);
+    this->LoadPackageRegistryDir(fname);
     }
 #else
   if(const char* home = cmSystemTools::GetEnv("HOME"))
@@ -1256,14 +1209,13 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
     std::string dir = home;
     dir += "/.cmake/packages/";
     dir += this->Name;
-    this->LoadPackageRegistryDir(dir,
-                                 this->LabeledPaths[PathLabel::UserRegistry]);
+    this->LoadPackageRegistryDir(dir);
     }
 #endif
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesSystemRegistry()
+void cmFindPackageCommand::AddPrefixesSystemRegistry()
 {
   if(this->NoSystemRegistry || this->NoDefaultPath)
     {
@@ -1289,32 +1241,29 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
 void cmFindPackageCommand::LoadPackageRegistryWinUser()
 {
   // HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views.
-  this->LoadPackageRegistryWin(true, 0,
-                               this->LabeledPaths[PathLabel::UserRegistry]);
+  this->LoadPackageRegistryWin(true, 0);
 }
 
 //----------------------------------------------------------------------------
 void cmFindPackageCommand::LoadPackageRegistryWinSystem()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemRegistry];
-
   // HKEY_LOCAL_MACHINE\\SOFTWARE has separate 32-bit and 64-bit views.
   // Prefer the target platform view first.
   if(this->Makefile->PlatformIs64Bit())
     {
-    this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
-    this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
+    this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY);
+    this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY);
     }
   else
     {
-    this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
-    this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
+    this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY);
+    this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY);
     }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
-                                                  cmSearchPath& outPaths)
+void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
+                                                  unsigned int view)
 {
   std::wstring key = L"Software\\Kitware\\CMake\\Packages\\";
   key += cmsys::Encoding::ToWide(this->Name);
@@ -1340,8 +1289,8 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
           if(valueType == REG_SZ)
             {
             data[dataSize] = 0;
-            if(!this->CheckPackageRegistryEntry(
-                  cmsys::Encoding::ToNarrow(&data[0]), outPaths))
+            cmsys_ios::stringstream ss(cmsys::Encoding::ToNarrow(&data[0]));
+            if(!this->CheckPackageRegistryEntry(ss))
               {
               // The entry is invalid.
               bad.insert(name);
@@ -1383,8 +1332,7 @@ public:
 };
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
-                                                  cmSearchPath& outPaths)
+void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir)
 {
   cmsys::Directory files;
   if(!files.Load(dir))
@@ -1406,9 +1354,7 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
 
       // Load the file.
       cmsys::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary);
-      std::string fentry;
-      if(fin && cmSystemTools::GetLineFromStream(fin, fentry) &&
-         this->CheckPackageRegistryEntry(fentry, outPaths))
+      if(fin && this->CheckPackageRegistryEntry(fin))
         {
         // The file references an existing package, so release it.
         holdFile.Release();
@@ -1421,11 +1367,12 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
 #endif
 
 //----------------------------------------------------------------------------
-bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
-                                                     cmSearchPath& outPaths)
+bool cmFindPackageCommand::CheckPackageRegistryEntry(std::istream& is)
 {
   // Parse the content of one package registry entry.
-  if(cmSystemTools::FileIsFullPath(fname.c_str()))
+  std::string fname;
+  if(cmSystemTools::GetLineFromStream(is, fname) &&
+     cmSystemTools::FileIsFullPath(fname.c_str()))
     {
     // The first line in the stream is the full path to a file or
     // directory containing the package.
@@ -1434,12 +1381,9 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
       // The path exists.  Look for the package here.
       if(!cmSystemTools::FileIsDirectory(fname))
         {
-        outPaths.AddPath(cmSystemTools::GetFilenamePath(fname));
-        }
-      else
-        {
-        outPaths.AddPath(fname);
+        fname = cmSystemTools::GetFilenamePath(fname);
         }
+      this->AddPathInternal(fname, FullPath);
       return true;
       }
     else
@@ -1460,60 +1404,52 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesBuilds()
+void cmFindPackageCommand::AddPrefixesBuilds()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Builds];
-
-  // It is likely that CMake will have recently built the project.
-  for(int i=0; i <= 10; ++i)
-    {
-    cmOStringStream r;
-    r <<
-      "[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\"
-      "Settings\\StartPath;WhereBuild" << i << "]";
-    std::string f = r.str();
-    cmSystemTools::ExpandRegistryValues(f);
-    cmSystemTools::ConvertToUnixSlashes(f);
-    if(cmSystemTools::FileIsFullPath(f.c_str()) &&
-       cmSystemTools::FileIsDirectory(f.c_str()))
-      {
-      paths.AddPath(f);
+  if(!this->NoBuilds && !this->NoDefaultPath)
+    {
+    // It is likely that CMake will have recently built the project.
+    for(int i=0; i <= 10; ++i)
+      {
+      cmOStringStream r;
+      r <<
+        "[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\"
+        "Settings\\StartPath;WhereBuild" << i << "]";
+      std::string f = r.str();
+      cmSystemTools::ExpandRegistryValues(f);
+      cmSystemTools::ConvertToUnixSlashes(f);
+      if(cmSystemTools::FileIsFullPath(f.c_str()) &&
+         cmSystemTools::FileIsDirectory(f))
+        {
+        this->AddPathInternal(f, FullPath);
+        }
       }
     }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
+void cmFindPackageCommand::AddPrefixesCMakeSystemVariable()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem];
-
-  paths.AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
-  paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
-  paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
+  if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
+    {
+    this->AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
+    this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
+    this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
+    }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesUserGuess()
+void cmFindPackageCommand::AddPrefixesUserGuess()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess];
-
-  for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin();
-      p != this->UserGuessArgs.end(); ++p)
-    {
-    paths.AddUserPath(*p);
-    }
+  // Add guesses specified by the caller.
+  this->AddPathsInternal(this->UserPaths, CMakePath);
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::FillPrefixesUserHints()
+void cmFindPackageCommand::AddPrefixesUserHints()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints];
-
-  for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin();
-      p != this->UserHintsArgs.end(); ++p)
-    {
-    paths.AddUserPath(*p);
-    }
+  // Add hints specified by the caller.
+  this->AddPathsInternal(this->UserHints, CMakePath);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 949dcb1..2249459 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -53,21 +53,6 @@ public:
 
   cmTypeMacro(cmFindPackageCommand, cmFindCommon);
 private:
-  class PathLabel : public cmFindCommon::PathLabel
-  {
-  protected:
-    PathLabel();
-  public:
-    PathLabel(const std::string& label) : cmFindCommon::PathLabel(label) { }
-    static PathLabel UserRegistry;
-    static PathLabel Builds;
-    static PathLabel SystemRegistry;
-  };
-
-  // Add additional search path labels and groups not present in the
-  // parent class
-  void AppendSearchPathGroups();
-
   void AppendSuccessInformation();
   void AppendToFoundProperty(bool found);
   void SetModuleVariables(const std::string& components);
@@ -84,22 +69,20 @@ private:
   void StoreVersionFound();
 
   void ComputePrefixes();
-  void FillPrefixesCMakeEnvironment();
-  void FillPrefixesCMakeVariable();
-  void FillPrefixesSystemEnvironment();
-  void FillPrefixesUserRegistry();
-  void FillPrefixesSystemRegistry();
-  void FillPrefixesBuilds();
-  void FillPrefixesCMakeSystemVariable();
-  void FillPrefixesUserGuess();
-  void FillPrefixesUserHints();
-  void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths);
+  void AddPrefixesCMakeEnvironment();
+  void AddPrefixesCMakeVariable();
+  void AddPrefixesSystemEnvironment();
+  void AddPrefixesUserRegistry();
+  void AddPrefixesSystemRegistry();
+  void AddPrefixesBuilds();
+  void AddPrefixesCMakeSystemVariable();
+  void AddPrefixesUserGuess();
+  void AddPrefixesUserHints();
+  void LoadPackageRegistryDir(std::string const& dir);
   void LoadPackageRegistryWinUser();
   void LoadPackageRegistryWinSystem();
-  void LoadPackageRegistryWin(bool user, unsigned int view,
-                              cmSearchPath& outPaths);
-  bool CheckPackageRegistryEntry(const std::string& fname,
-                                 cmSearchPath& outPaths);
+  void LoadPackageRegistryWin(bool user, unsigned int view);
+  bool CheckPackageRegistryEntry(std::istream& is);
   bool SearchDirectory(std::string const& dir);
   bool CheckDirectory(std::string const& dir);
   bool FindConfigFile(std::string const& dir, std::string& file);
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
deleted file mode 100644
index 38446f5..0000000
--- a/Source/cmPathLabel.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-
-#include "cmPathLabel.h"
-
-//----------------------------------------------------------------------------
-cmPathLabel::cmPathLabel(const std::string& label)
-: Label(label), Hash(0)
-{
-  for(size_t i = 0; i < this->Label.size(); ++i)
-    {
-    this->Hash += this->Label[i];
-    this->Hash += (this->Hash << 10);
-    this->Hash ^= (this->Hash >> 6);
-    }
-  this->Hash += (this->Hash << 3);
-  this->Hash ^= (this->Hash >> 11);
-  this->Hash += (this->Hash << 15);
-}
-
-//----------------------------------------------------------------------------
-bool cmPathLabel::operator < (const cmPathLabel& l) const
-{
-  return this->Hash < l.Hash;
-}
-
-//----------------------------------------------------------------------------
-bool cmPathLabel::operator == (const cmPathLabel& l) const
-{
-  return this->Hash == l.Hash;
-}
diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h
deleted file mode 100644
index 3cc9372..0000000
--- a/Source/cmPathLabel.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#ifndef cmPathLabel_h
-#define cmPathLabel_h
-
-#include "cmStandardIncludes.h"
-
-/** \class cmPathLabel
- * \brief Helper class for text based labels
- *
- * cmPathLabel is extended in differnt classes to act as an inheritable
- * enum.  Comparisons are done on a precomputed Jenkins hash of the string
- * label for indexing and searchig.
- */
-class cmPathLabel
-{
-public:
-  cmPathLabel(const std::string& label);
-
-  // The compatison operators are only for quick sorting and searching and
-  // in no way imply any lexicographical order of the label
-  bool operator < (const cmPathLabel& l) const;
-  bool operator == (const cmPathLabel& l) const;
-
-  const std::string& GetLabel() const { return this->Label; }
-  const int& GetHash() const { return this->Hash; }
-
-protected:
-  cmPathLabel();
-
-  std::string Label;
-  int Hash;
-};
-
-#endif
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
deleted file mode 100644
index 1551127..0000000
--- a/Source/cmSearchPath.cxx
+++ /dev/null
@@ -1,242 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-
-#include "cmSearchPath.h"
-#include "cmFindCommon.h"
-
-//----------------------------------------------------------------------------
-cmSearchPath::cmSearchPath(cmFindCommon* findCmd)
-: FC(findCmd)
-{
-  assert(findCmd != NULL);
-}
-
-//----------------------------------------------------------------------------
-cmSearchPath::~cmSearchPath()
-{
-}
-
-//----------------------------------------------------------------------------
-
-void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore,
-                                  std::vector<std::string>& outPaths,
-                                  bool clear) const
-{
-  if(clear)
-    {
-    outPaths.clear();
-    }
-  for(std::vector<std::string>::const_iterator p = this->Paths.begin();
-      p != this->Paths.end(); ++p)
-    {
-    if(ignore.count(*p) == 0)
-      {
-      outPaths.push_back(*p);
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddPath(const std::string& path)
-{
-  this->AddPathInternal(path);
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddUserPath(const std::string& path)
-{
-  std::vector<std::string> outPaths;
-
-  // We should view the registry as the target application would view
-  // it.
-  cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
-  cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
-  if(this->FC->Makefile->PlatformIs64Bit())
-    {
-    view = cmSystemTools::KeyWOW64_64;
-    other_view = cmSystemTools::KeyWOW64_32;
-    }
-
-  // Expand using the view of the target application.
-  std::string expanded = path;
-  cmSystemTools::ExpandRegistryValues(expanded, view);
-  cmSystemTools::GlobDirs(expanded, outPaths);
-
-  // Executables can be either 32-bit or 64-bit, so expand using the
-  // alternative view.
-  if(expanded != path && this->FC->CMakePathName == "PROGRAM")
-    {
-    expanded = path;
-    cmSystemTools::ExpandRegistryValues(expanded, other_view);
-    cmSystemTools::GlobDirs(expanded, outPaths);
-    }
-
-  // Process them all from the current directory
-  for(std::vector<std::string>::const_iterator p = outPaths.begin();
-      p != outPaths.end(); ++p)
-    {
-    this->AddPathInternal(*p, this->FC->Makefile->GetCurrentDirectory());
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddCMakePath(const std::string& variable)
-{
-  // Get a path from a CMake variable.
-  if(const char* value = this->FC->Makefile->GetDefinition(variable))
-    {
-    std::vector<std::string> expanded;
-    cmSystemTools::ExpandListArgument(value, expanded);
-
-    for(std::vector<std::string>::const_iterator p = expanded.begin();
-        p!= expanded.end(); ++p)
-      {
-      this->AddPathInternal(*p, this->FC->Makefile->GetCurrentDirectory());
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddEnvPath(const std::string& variable)
-{
-  std::vector<std::string> expanded;
-  cmSystemTools::GetPath(expanded, variable.c_str());
-  for(std::vector<std::string>::const_iterator p = expanded.begin();
-      p!= expanded.end(); ++p)
-    {
-    this->AddPathInternal(*p);
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddCMakePrefixPath(const std::string& variable)
-{
-  // Get a path from a CMake variable.
-  if(const char* value = this->FC->Makefile->GetDefinition(variable))
-    {
-    std::vector<std::string> expanded;
-    cmSystemTools::ExpandListArgument(value, expanded);
-
-    this->AddPrefixPaths(expanded, this->FC->Makefile->GetCurrentDirectory());
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddEnvPrefixPath(const std::string& variable)
-{
-  std::vector<std::string> expanded;
-  cmSystemTools::GetPath(expanded, variable.c_str());
-  this->AddPrefixPaths(expanded);
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
-{
-  std::vector<std::string> inPaths;
-  inPaths.swap(this->Paths);
-  this->Paths.reserve(inPaths.size()*(suffixes.size()+1));
-
-  for(std::vector<std::string>::iterator ip = inPaths.begin();
-      ip != inPaths.end(); ++ip)
-    {
-    cmSystemTools::ConvertToUnixSlashes(*ip);
-
-    // if *i is only / then do not add a //
-    // this will get incorrectly considered a network
-    // path on windows and cause huge delays.
-    std::string p = *ip;
-    if(!p.empty() && *p.rbegin() != '/')
-      {
-      p += "/";
-      }
-
-    // Combine with all the suffixes
-    for(std::vector<std::string>::const_iterator s = suffixes.begin();
-        s != suffixes.end(); ++s)
-      {
-      this->Paths.push_back(p+*s);
-      }
-
-    // And now the original w/o any suffix
-    this->Paths.push_back(*ip);
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
-                                  const char *base)
-{
-  // default for programs
-  std::string subdir = "bin";
-
-  if (this->FC->CMakePathName == "INCLUDE")
-    {
-    subdir = "include";
-    }
-  else if (this->FC->CMakePathName == "LIBRARY")
-    {
-    subdir = "lib";
-    }
-  else if (this->FC->CMakePathName == "FRAMEWORK")
-    {
-    subdir = "";  // ? what to do for frameworks ?
-    }
-
-  for(std::vector<std::string>::const_iterator p = paths.begin();
-      p != paths.end(); ++p)
-    {
-    std::string dir = *p;
-    if(!subdir.empty() && !dir.empty() && *dir.rbegin() != '/')
-      {
-      dir += "/";
-      }
-    if(subdir == "include" || subdir == "lib")
-      {
-      const char* arch =
-        this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE");
-      if(arch && *arch)
-        {
-        this->AddPathInternal(dir+subdir+"/"+arch, base);
-        }
-      }
-    std::string add = dir + subdir;
-    if(add != "/")
-      {
-      this->AddPathInternal(add, base);
-      }
-    if (subdir == "bin")
-      {
-      this->AddPathInternal(dir+"sbin", base);
-      }
-    if(!subdir.empty() && *p != "/")
-      {
-      this->AddPathInternal(*p, base);
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmSearchPath::AddPathInternal(const std::string& path, const char *base)
-{
-  std::string collapsed = cmSystemTools::CollapseFullPath(path, base);
-
-   if(collapsed.empty())
-    {
-    return;
-    }
-
-  // Insert the path if has not already been emitted.
-  if(this->FC->SearchPathsEmitted.insert(collapsed).second)
-    {
-    this->Paths.push_back(collapsed);
-    }
-}
diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h
deleted file mode 100644
index 51a6149..0000000
--- a/Source/cmSearchPath.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#ifndef cmSearchPath_h
-#define cmSearchPath_h
-
-#include "cmStandardIncludes.h"
-
-class cmFindCommon;
-
-/** \class cmSearchPath
- * \brief Container for encapsulating a set of search paths
- *
- * cmSearchPath is a container that encapsulates search path construction and
- * management
- */
-class cmSearchPath
-{
-public:
-  // cmSearchPath must be initialized from a valid pointer.  The only reason
-  // for teh default is to allow it to be easily used in stl containers.
-  // Attempting to initialize with a NULL value will fail an assertion
-  cmSearchPath(cmFindCommon* findCmd = 0);
-  ~cmSearchPath();
-
-  const std::vector<std::string>& GetPaths() const { return this->Paths; }
-
-  void ExtractWithout(const std::set<std::string>& ignore,
-                      std::vector<std::string>& outPaths,
-                      bool clear = false) const;
-
-  void AddPath(const std::string& path);
-  void AddUserPath(const std::string& path);
-  void AddCMakePath(const std::string& variable);
-  void AddEnvPath(const std::string& variable);
-  void AddCMakePrefixPath(const std::string& variable);
-  void AddEnvPrefixPath(const std::string& variable);
-  void AddSuffixes(const std::vector<std::string>& suffixes);
-
-protected:
-  void AddPrefixPaths(const std::vector<std::string>& paths,
-                      const char *base = 0);
-  void AddPathInternal(const std::string& path, const char *base = 0);
-
-  cmFindCommon *FC;
-  std::vector<std::string> Paths;
-};
-
-#endif

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

Summary of changes:
 Source/cmBootstrapCommands1.cxx |    2 -
 Source/cmFindBase.cxx           |  274 ++++++++++++++++++++++++-------------
 Source/cmFindBase.h             |   19 ++-
 Source/cmFindCommon.cxx         |  200 ++++++++++++++++-----------
 Source/cmFindCommon.h           |   66 +++------
 Source/cmFindLibraryCommand.cxx |    2 +-
 Source/cmFindPackageCommand.cxx |  286 +++++++++++++++------------------------
 Source/cmFindPackageCommand.h   |   41 ++----
 Source/cmPathLabel.cxx          |   40 ------
 Source/cmPathLabel.h            |   44 ------
 Source/cmSearchPath.cxx         |  242 ---------------------------------
 Source/cmSearchPath.h           |   57 --------
 12 files changed, 457 insertions(+), 816 deletions(-)
 delete mode 100644 Source/cmPathLabel.cxx
 delete mode 100644 Source/cmPathLabel.h
 delete mode 100644 Source/cmSearchPath.cxx
 delete mode 100644 Source/cmSearchPath.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list