[Cmake-commits] [cmake-commits] king committed cmFindBase.cxx 1.41 1.42 cmFindBase.h 1.13 1.14 cmFindCommon.cxx 1.1 1.2 cmFindCommon.h 1.1 1.2 cmFindPackageCommand.cxx 1.36 1.37 cmFindPackageCommand.h 1.19 1.20

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jun 5 18:20:18 EDT 2008


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

Modified Files:
	cmFindBase.cxx cmFindBase.h cmFindCommon.cxx cmFindCommon.h 
	cmFindPackageCommand.cxx cmFindPackageCommand.h 
Log Message:
ENH: Refactor cmFindCommon, cmFindBase, and cmFindPackageCommand

  - Add each part of the search order in a separate method.
  - Collect added paths in an ivar in cmFindCommon.
  - Move user path storage up to cmFindCommon and share
    between cmFindBase and cmFindPackageCommand.
  - Expand user path registry values up in cmFindCommon
    - Enables 32-/64-bit registry view for find_package
    - Disables registry expansion for paths not specified
      with the PATHS argument, which is not expected.


Index: cmFindBase.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindBase.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -C 2 -d -r1.41 -r1.42
*** cmFindBase.cxx	5 Jun 2008 13:54:28 -0000	1.41
--- cmFindBase.cxx	5 Jun 2008 22:20:16 -0000	1.42
***************
*** 162,166 ****
    this->SelectDefaultMacMode();
  
-   std::vector<std::string> userPaths;
    std::string doc;
    bool doingNames = true; // assume it starts with a name
--- 162,165 ----
***************
*** 214,219 ****
          }
        else if(doingPaths)
!         { 
!         userPaths.push_back(args[j]);
          }
        else if(doingPathSuf)
--- 213,218 ----
          }
        else if(doingPaths)
!         {
!         this->AddUserPath(args[j]);
          }
        else if(doingPathSuf)
***************
*** 267,274 ****
      for(unsigned int j = 2; j < args.size(); ++j)
        {
!       userPaths.push_back(args[j]);
        }
      }
!   this->ExpandPaths(userPaths);
  
    // Handle search root stuff.
--- 266,273 ----
      for(unsigned int j = 2; j < args.size(); ++j)
        {
!       this->AddUserPath(args[j]);
        }
      }
!   this->ExpandPaths();
  
    // Handle search root stuff.
***************
*** 277,281 ****
  }
  
! void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
  {
    // if NO Default paths was not specified add the
--- 276,280 ----
  }
  
! void cmFindBase::ExpandPaths()
  {
    // if NO Default paths was not specified add the
***************
*** 285,356 ****
      if(this->SearchFrameworkFirst || this->SearchFrameworkOnly)
        {
!       this->AddFrameWorkPaths();
        }
      if(this->SearchAppBundleFirst || this->SearchAppBundleOnly)
        {
!       this->AddAppBundlePaths();
!       }
!     if(!this->NoCMakeEnvironmentPath && 
!        !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
!       {
!       // Add CMAKE_*_PATH environment variables
!       this->AddEnvironmentVariables();
!       }
!     if(!this->NoCMakePath && 
!        !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
!       {
!       // 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
!       this->AddCMakeVariables();
!       }
!     if(!this->NoSystemEnvironmentPath && 
!        !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
!       {
!       // add System environment PATH and (LIB or INCLUDE)
!       this->AddSystemEnvironmentVariables();
!       }
!     if(!this->NoCMakeSystemPath && 
!        !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
!       {
!       // Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files
!       this->AddCMakeSystemVariables();
        }
      if(this->SearchAppBundleLast)
        {
!       this->AddAppBundlePaths();
        }
      if(this->SearchFrameworkLast)
        {
!       this->AddFrameWorkPaths();
        }
      }
-   std::vector<std::string> paths;
-   // add the paths specified in the FIND_* call 
-   for(unsigned int i =0; i < userPaths.size(); ++i)
-     {
-     paths.push_back(userPaths[i]);
-     }
-   this->AddPaths(paths);
- }
- 
- //----------------------------------------------------------------------------
- void cmFindBase::AddEnvironmentVariables()
- { 
-   std::vector<std::string> paths;
  
!   std::vector<std::string> prefixPaths;
!   cmSystemTools::GetPath(prefixPaths, "CMAKE_PREFIX_PATH");
!   this->AddFindPrefix(paths, prefixPaths);
  
!   std::string var = "CMAKE_";
!   var += this->CMakePathName;
!   var += "_PATH";
!   cmSystemTools::GetPath(paths, var.c_str());
!   this->AddPaths(paths);
  }
  
! void cmFindBase::AddFindPrefix(std::vector<std::string>& dest, 
!                                const std::vector<std::string>& src)
  {
    // default for programs
--- 284,317 ----
      if(this->SearchFrameworkFirst || this->SearchFrameworkOnly)
        {
!       this->AddFrameworkPath();
        }
      if(this->SearchAppBundleFirst || this->SearchAppBundleOnly)
        {
!       this->AddAppBundlePath();
        }
+     this->AddCMakeEnvironmentPath();
+     this->AddCMakeVariablePath();
+     this->AddSystemEnvironmentPath();
+     this->AddCMakeSystemVariablePath();
      if(this->SearchAppBundleLast)
        {
!       this->AddAppBundlePath();
        }
      if(this->SearchFrameworkLast)
        {
!       this->AddFrameworkPath();
        }
      }
  
!   // Add paths specified by the caller.
!   this->AddPathsInternal(this->UserPaths, CMakePath);
  
!   // Add suffixes and clean up paths.
!   this->AddPathSuffixes();
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
!                                 PathType pathType)
  {
    // default for programs
***************
*** 370,376 ****
      }
  
!   for (std::vector<std::string>::const_iterator it = src.begin();
!        it != src.end();
!        ++it)
      {
      std::string dir = it->c_str();
--- 331,336 ----
      }
  
!   for(std::vector<std::string>::const_iterator it = in_paths.begin();
!       it != in_paths.end(); ++it)
      {
      std::string dir = it->c_str();
***************
*** 382,510 ****
      if(add != "/")
        {
!       dest.push_back(add);
        }
      if (subdir == "bin")
        {
!       dest.push_back(dir + "sbin");
        }
      if(!subdir.empty() && *it != "/")
        {
!       dest.push_back(*it);
        }
      }
  }
  
! void cmFindBase::AddFrameWorkPaths()
  {
!   std::vector<std::string> paths;
!   this->GetFrameworkPaths(paths);
!   this->AddPaths(paths);
  }
  
! void cmFindBase::AddPaths(std::vector<std::string> & paths)
  {
!   // add suffixes and clean up paths
!   this->ExpandRegistryAndCleanPath(paths);
!   // add the paths to the search paths
!   this->SearchPaths.insert(this->SearchPaths.end(),
!                            paths.begin(),
!                            paths.end());
  }
  
! void cmFindBase::AddAppBundlePaths()
  {
!   std::vector<std::string> paths;
!   this->GetAppBundlePaths(paths);
!   this->AddPaths(paths);
! }
  
! void cmFindBase::AddCMakeVariables()
! { 
!   std::string var = "CMAKE_";
!   var += this->CMakePathName;
!   var += "_PATH";
!   std::vector<std::string> paths;
  
!   if(const char* prefixPath = 
!       this->Makefile->GetDefinition("CMAKE_PREFIX_PATH"))
      {
!     std::vector<std::string> prefixPaths;
!     cmSystemTools::ExpandListArgument(prefixPath, prefixPaths);
!     this->AddFindPrefix(paths, prefixPaths);
      }
  
!   if(const char* path = this->Makefile->GetDefinition(var.c_str()))
      {
!     cmSystemTools::ExpandListArgument(path, paths);
!     } 
!   this->AddPaths(paths);
  }
  
! void cmFindBase::AddSystemEnvironmentVariables()
  {
!   // Add LIB or INCLUDE
!   std::vector<std::string> paths;
!   if(this->EnvironmentPath.size())
      {
!     cmSystemTools::GetPath(paths, this->EnvironmentPath.c_str());
      }
-   // Add PATH 
-   cmSystemTools::GetPath(paths);
-   this->AddPaths(paths);
  }
  
! void cmFindBase::AddCMakeSystemVariables()
! {  
!   std::string var = "CMAKE_SYSTEM_";
!   var += this->CMakePathName;
!   var += "_PATH";
!   std::vector<std::string> paths;
!   if(const char* prefixPath =
!       this->Makefile->GetDefinition("CMAKE_SYSTEM_PREFIX_PATH"))
      {
!     std::vector<std::string> prefixPaths;
!     cmSystemTools::ExpandListArgument(prefixPath, prefixPaths);
!     this->AddFindPrefix(paths, prefixPaths);
      }
-   if(const char* path = this->Makefile->GetDefinition(var.c_str()))
-     {
-     cmSystemTools::ExpandListArgument(path, paths);
-     }  
-   this->AddPaths(paths);
  }
  
! void cmFindBase::ExpandRegistryAndCleanPath(std::vector<std::string>& paths)
  {
!   // 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(const char* psize =
!      this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P"))
      {
!     if(atoi(psize) == 8)
        {
!       view = cmSystemTools::KeyWOW64_64;
!       other_view = cmSystemTools::KeyWOW64_32;
        }
      }
!   std::vector<std::string> finalPath;
!   std::vector<std::string>::iterator i;
!   // glob and expand registry stuff from paths and put
!   // into finalPath
!   for(i = paths.begin();
!       i != paths.end(); ++i)
      {
!     std::string expanded = *i;
!     cmSystemTools::ExpandRegistryValues(expanded, view);
!     cmSystemTools::GlobDirs(expanded.c_str(), finalPath);
!     if(expanded != *i && this->CMakePathName == "PROGRAM")
!       {
!       // Executables can be either 32-bit or 64-bit.
!       expanded = *i;
!       cmSystemTools::ExpandRegistryValues(expanded, other_view);
!       cmSystemTools::GlobDirs(expanded.c_str(), finalPath);
!       }
      }
    // clear the path
    paths.clear();
--- 342,486 ----
      if(add != "/")
        {
!       this->AddPathInternal(add, pathType);
        }
      if (subdir == "bin")
        {
!       this->AddPathInternal(dir+"sbin", pathType);
        }
      if(!subdir.empty() && *it != "/")
        {
!       this->AddPathInternal(*it, pathType);
        }
      }
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddCMakePrefixPath(const char* 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);
!     this->AddPrefixPaths(tmp, CMakePath);
!     }
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddEnvPrefixPath(const char* variable)
  {
!   // Get a path from the environment.
!   std::vector<std::string> tmp;
!   cmSystemTools::GetPath(tmp, variable);
!   this->AddPrefixPaths(tmp, EnvPath);
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddMacPath(const char* var, const char* sysvar)
  {
!   if(this->NoDefaultPath)
!     {
!     return;
!     }
  
!   // first environment variables
!   if(!this->NoCMakeEnvironmentPath)
!     {
!     this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
!     }
  
!   // add cmake variables
!   if(!this->NoCMakePath)
      {
!     this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
      }
  
!   // add cmake system variables
!   if(!this->NoCMakeSystemPath)
      {
!     this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
!     }
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddFrameworkPath()
  {
!   this->AddMacPath("CMAKE_FRAMEWORK_PATH", "CMAKE_SYSTEM_FRAMEWORK_PATH");
! }
! 
! //----------------------------------------------------------------------------
! void cmFindBase::AddAppBundlePath()
! {
!   this->AddMacPath("CMAKE_APPBUNDLE_PATH", "CMAKE_SYSTEM_APPBUNDLE_PATH");
! }
! 
! //----------------------------------------------------------------------------
! void cmFindBase::AddCMakeEnvironmentPath()
! {
!   if(!this->NoCMakeEnvironmentPath &&
!      !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
      {
!     // Add CMAKE_*_PATH environment variables
!     std::string var = "CMAKE_";
!     var += this->CMakePathName;
!     var += "_PATH";
!     this->AddEnvPrefixPath("CMAKE_PREFIX_PATH");
!     this->AddEnvPath(var.c_str());
      }
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddCMakeVariablePath()
! {
!   if(!this->NoCMakePath &&
!      !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
      {
!     // 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.c_str());
      }
  }
  
! //----------------------------------------------------------------------------
! void cmFindBase::AddSystemEnvironmentPath()
  {
!   if(!this->NoSystemEnvironmentPath &&
!      !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
      {
!     // Add LIB or INCLUDE
!     if(!this->EnvironmentPath.empty())
        {
!       this->AddEnvPath(this->EnvironmentPath.c_str());
        }
+     // Add PATH
+     this->AddEnvPath(0);
      }
! }
! 
! //----------------------------------------------------------------------------
! void cmFindBase::AddCMakeSystemVariablePath()
! {
!   if(!this->NoCMakeSystemPath &&
!      !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
      {
!     std::string var = "CMAKE_SYSTEM_";
!     var += this->CMakePathName;
!     var += "_PATH";
!     this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
!     this->AddCMakePath(var.c_str());
      }
+ }
+ 
+ //----------------------------------------------------------------------------
+ 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();

Index: cmFindCommon.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindCommon.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** cmFindCommon.cxx	17 Jan 2008 14:02:31 -0000	1.1
--- cmFindCommon.cxx	5 Jun 2008 22:20:16 -0000	1.2
***************
*** 323,413 ****
  
  //----------------------------------------------------------------------------
! void cmFindCommon::GetAppBundlePaths(std::vector<std::string>& paths)
  {
!   if(this->NoDefaultPath)
!     {
!     return;
!     }
!   std::vector<std::string> tmp;
! 
!   // first environment variables
!   if(!this->NoCMakeEnvironmentPath)
!     {
!     cmSystemTools::GetPath(tmp, "CMAKE_APPBUNDLE_PATH");
!     this->AddPathsInternal(paths, tmp, EnvPath);
!     tmp.clear();
!     }
! 
!   // add cmake variables
!   if(!this->NoCMakePath)
!     {
!     if(const char* path =
!        this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
!       {
!       cmSystemTools::ExpandListArgument(path, tmp);
!       this->AddPathsInternal(paths, tmp, CMakePath);
!       tmp.clear();
!       }
!     }
! 
!   // add cmake system variables
!   if(!this->NoCMakeSystemPath)
      {
!     if(const char* path =
!        this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
        {
!       cmSystemTools::ExpandListArgument(path, tmp);
!       this->AddPathsInternal(paths, tmp, CMakePath);
!       tmp.clear();
        }
      }
- }
- 
- //----------------------------------------------------------------------------
- void cmFindCommon::GetFrameworkPaths(std::vector<std::string>& paths)
- {
-   if(this->NoDefaultPath)
-     {
-     return;
-     }
-   std::vector<std::string> tmp;
- 
-   // first environment variables
-   if(!this->NoCMakeEnvironmentPath)
-     {
-     cmSystemTools::GetPath(tmp, "CMAKE_FRAMEWORK_PATH");
-     this->AddPathsInternal(paths, tmp, EnvPath);
-     tmp.clear();
-     }
  
!   // add cmake variables
!   if(!this->NoCMakePath)
!     {
!     if(const char* path =
!        this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
!       {
!       cmSystemTools::ExpandListArgument(path, tmp);
!       this->AddPathsInternal(paths, tmp, CMakePath);
!       tmp.clear();
!       }
!     }
  
!   // add cmake system variables
!   if(!this->NoCMakeSystemPath)
      {
!     if(const char* path =
!        this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
!       {
!       cmSystemTools::ExpandListArgument(path, tmp);
!       this->AddPathsInternal(paths, tmp, CMakePath);
!       tmp.clear();
!       }
      }
  }
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddCMakePath(std::vector<std::string>& out_paths,
!                                 const char* variable,
!                                 std::set<cmStdString>* emmitted)
  {
    // Get a path from a CMake variable.
--- 323,359 ----
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddUserPath(std::string const& p)
  {
!   // 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(const char* psize =
!      this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P"))
      {
!     if(atoi(psize) == 8)
        {
!       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.c_str(), this->UserPaths);
  
!   // 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.c_str(), this->UserPaths);
      }
  }
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddCMakePath(const char* variable)
  {
    // Get a path from a CMake variable.
***************
*** 419,430 ****
      // Relative paths are interpreted with respect to the current
      // source directory.
!     this->AddPathsInternal(out_paths, tmp, CMakePath, emmitted);
      }
  }
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddEnvPath(std::vector<std::string>& out_paths,
!                               const char* variable,
!                               std::set<cmStdString>* emmitted)
  {
    // Get a path from the environment.
--- 365,374 ----
      // 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.
***************
*** 434,458 ****
    // Relative paths are interpreted with respect to the current
    // working directory.
!   this->AddPathsInternal(out_paths, tmp, EnvPath, emmitted);
  }
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddPathsInternal(std::vector<std::string>& out_paths,
!                                     std::vector<std::string> const& in_paths,
!                                     PathType pathType,
!                                     std::set<cmStdString>* emmitted)
  {
    for(std::vector<std::string>::const_iterator i = in_paths.begin();
        i != in_paths.end(); ++i)
      {
!     this->AddPathInternal(out_paths, *i, pathType, emmitted);
      }
  }
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddPathInternal(std::vector<std::string>& out_paths,
!                                    std::string const& in_path,
!                                    PathType pathType,
!                                    std::set<cmStdString>* emmitted)
  {
    if(in_path.empty())
--- 378,398 ----
    // 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)
  {
    if(in_path.empty())
***************
*** 472,479 ****
      cmSystemTools::CollapseFullPath(in_path.c_str(), relbase);
  
!   // Insert the path if has not already been emmitted.
!   if(!emmitted || emmitted->insert(fullPath).second)
      {
!     out_paths.push_back(fullPath.c_str());
      }
  }
--- 412,419 ----
      cmSystemTools::CollapseFullPath(in_path.c_str(), relbase);
  
!   // Insert the path if has not already been emitted.
!   if(this->SearchPathsEmitted.insert(fullPath).second)
      {
!     this->SearchPaths.push_back(fullPath.c_str());
      }
  }

Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** cmFindPackageCommand.h	29 Jan 2008 01:38:48 -0000	1.19
--- cmFindPackageCommand.h	5 Jun 2008 22:20:16 -0000	1.20
***************
*** 83,88 ****
    void StoreVersionFound();
  
-   void AddUserPath(std::string const& p);
    void ComputePrefixes();
    bool SearchDirectory(std::string const& dir);
    bool CheckDirectory(std::string const& dir);
--- 83,94 ----
    void StoreVersionFound();
  
    void ComputePrefixes();
+   void AddPrefixesCMakeEnvironment();
+   void AddPrefixesCMakeVariable();
+   void AddPrefixesSystemEnvironment();
+   void AddPrefixesBuilds();
+   void AddPrefixesCMakeSystemVariable();
+   void AddPrefixesUser();
+   void ComputeFinalPrefixes();
    bool SearchDirectory(std::string const& dir);
    bool CheckDirectory(std::string const& dir);
***************
*** 120,125 ****
    std::vector<std::string> Names;
    std::vector<std::string> Configs;
-   std::vector<std::string> Prefixes;
-   std::vector<std::string> UserPaths;
  };
  
--- 126,129 ----

Index: cmFindCommon.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindCommon.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** cmFindCommon.h	17 Jan 2008 14:02:31 -0000	1.1
--- cmFindCommon.h	5 Jun 2008 22:20:16 -0000	1.2
***************
*** 56,74 ****
    bool CheckCommonArgument(std::string const& arg);
    void AddPathSuffix(std::string const& arg);
!   void GetAppBundlePaths(std::vector<std::string>& paths);
!   void GetFrameworkPaths(std::vector<std::string>& paths);
! 
!   void AddCMakePath(std::vector<std::string>& out_paths,
!                     const char* variable, std::set<cmStdString>* emmitted = 0);
!   void AddEnvPath(std::vector<std::string>& out_paths,
!                   const char* variable, std::set<cmStdString>* emmitted = 0);
!   void AddPathsInternal(std::vector<std::string>& out_paths,
!                         std::vector<std::string> const& in_paths,
!                         PathType pathType,
!                         std::set<cmStdString>* emmitted = 0);
!   void AddPathInternal(std::vector<std::string>& out_paths,
!                        std::string const& in_path,
!                        PathType pathType,
!                        std::set<cmStdString>* emmitted = 0);
  
    bool NoDefaultPath;
--- 56,65 ----
    bool CheckCommonArgument(std::string const& arg);
    void AddPathSuffix(std::string const& arg);
!   void AddUserPath(std::string const& p);
!   void AddCMakePath(const char* 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);
  
    bool NoDefaultPath;
***************
*** 79,82 ****
--- 70,76 ----
  
    std::vector<std::string> SearchPathSuffixes;
+   std::vector<std::string> UserPaths;
+   std::vector<std::string> SearchPaths;
+   std::set<cmStdString> SearchPathsEmitted;
  
    std::string GenericDocumentationMacPolicy;

Index: cmFindBase.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindBase.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C 2 -d -r1.13 -r1.14
*** cmFindBase.h	17 Jan 2008 14:02:31 -0000	1.13
--- cmFindBase.h	5 Jun 2008 22:20:16 -0000	1.14
***************
*** 42,58 ****
  protected:
    void PrintFindStuff();
!   void ExpandPaths(std::vector<std::string> userPaths);
  
-   // add to the SearchPaths
-   void AddPaths(std::vector<std::string>& paths);
-   void AddFrameWorkPaths();
-   void AddAppBundlePaths();
-   void AddEnvironmentVariables();
-   void AddFindPrefix(std::vector<std::string>& dest, 
-                      const std::vector<std::string>& src);
-   void AddCMakeVariables();
-   void AddSystemEnvironmentVariables();
-   void AddCMakeSystemVariables();
-   void ExpandRegistryAndCleanPath(std::vector<std::string>& paths);
    // see if the VariableName is already set in the cache,
    // also copy the documentation from the cache to VariableDocumentation
--- 42,48 ----
  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
***************
*** 65,69 ****
    cmStdString VariableName;
    std::vector<std::string> Names;
-   std::vector<std::string> SearchPaths;
  
    // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM
--- 55,58 ----
***************
*** 72,75 ****
--- 61,79 ----
    bool AlreadyInCache;
    bool AlreadyInCacheWithoutMetaInfo;
+ private:
+   // Add pieces of the search.
+   void AddFrameworkPath();
+   void AddAppBundlePath();
+   void AddCMakeEnvironmentPath();
+   void AddCMakeVariablePath();
+   void AddSystemEnvironmentPath();
+   void AddCMakeSystemVariablePath();
+ 
+   // Helpers.
+   void AddMacPath(const char* var, const char* sysvar);
+   void AddCMakePrefixPath(const char* variable);
+   void AddEnvPrefixPath(const char* variable);
+   void AddPrefixPaths(std::vector<std::string> const& in_paths,
+                       PathType pathType);
  };
  

Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -C 2 -d -r1.36 -r1.37
*** cmFindPackageCommand.cxx	29 Jan 2008 14:57:39 -0000	1.36
--- cmFindPackageCommand.cxx	5 Jun 2008 22:20:16 -0000	1.37
***************
*** 822,827 ****
  bool cmFindPackageCommand::FindPrefixedConfig()
  {
!   for(std::vector<std::string>::const_iterator pi = this->Prefixes.begin();
!       pi != this->Prefixes.end(); ++pi)
      {
      if(this->SearchPrefix(*pi))
--- 822,828 ----
  bool cmFindPackageCommand::FindPrefixedConfig()
  {
!   std::vector<std::string>& prefixes = this->SearchPaths;
!   for(std::vector<std::string>::const_iterator pi = prefixes.begin();
!       pi != prefixes.end(); ++pi)
      {
      if(this->SearchPrefix(*pi))
***************
*** 836,841 ****
  bool cmFindPackageCommand::FindFrameworkConfig()
  {
!   for(std::vector<std::string>::const_iterator i = this->Prefixes.begin();
!       i != this->Prefixes.end(); ++i)
      {
      if(this->SearchFrameworkPrefix(*i))
--- 837,843 ----
  bool cmFindPackageCommand::FindFrameworkConfig()
  {
!   std::vector<std::string>& prefixes = this->SearchPaths;
!   for(std::vector<std::string>::const_iterator i = prefixes.begin();
!       i != prefixes.end(); ++i)
      {
      if(this->SearchFrameworkPrefix(*i))
***************
*** 850,855 ****
  bool cmFindPackageCommand::FindAppBundleConfig()
  {
!   for(std::vector<std::string>::const_iterator i = this->Prefixes.begin();
!       i != this->Prefixes.end(); ++i)
      {
      if(this->SearchAppBundlePrefix(*i))
--- 852,858 ----
  bool cmFindPackageCommand::FindAppBundleConfig()
  {
!   std::vector<std::string>& prefixes = this->SearchPaths;
!   for(std::vector<std::string>::const_iterator i = prefixes.begin();
!       i != prefixes.end(); ++i)
      {
      if(this->SearchAppBundlePrefix(*i))
***************
*** 940,956 ****
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::AddUserPath(std::string const& p)
  {
!   std::string userPath = p;
!   cmSystemTools::ExpandRegistryValues(userPath);
!   this->UserPaths.push_back(userPath);
  }
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::ComputePrefixes()
  {
-   std::vector<std::string>& prefixes = this->Prefixes;
-   std::set<cmStdString> emmitted;
- 
    if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
      {
--- 943,960 ----
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::ComputePrefixes()
  {
!   this->AddPrefixesCMakeEnvironment();
!   this->AddPrefixesCMakeVariable();
!   this->AddPrefixesSystemEnvironment();
!   this->AddPrefixesBuilds();
!   this->AddPrefixesCMakeSystemVariable();
!   this->AddPrefixesUser();
!   this->ComputeFinalPrefixes();
  }
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::AddPrefixesCMakeEnvironment()
  {
    if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
      {
***************
*** 961,979 ****
        {
        cmSystemTools::ConvertToUnixSlashes(env);
!       this->AddPathInternal(prefixes, env, EnvPath, &emmitted);
        }
  
!     this->AddEnvPath(prefixes, "CMAKE_PREFIX_PATH", &emmitted);
!     this->AddEnvPath(prefixes, "CMAKE_FRAMEWORK_PATH", &emmitted);
!     this->AddEnvPath(prefixes, "CMAKE_APPBUNDLE_PATH", &emmitted);
      }
  
    if(!this->NoCMakePath && !this->NoDefaultPath)
      {
!     this->AddCMakePath(prefixes, "CMAKE_PREFIX_PATH", &emmitted);
!     this->AddCMakePath(prefixes, "CMAKE_FRAMEWORK_PATH", &emmitted);
!     this->AddCMakePath(prefixes, "CMAKE_APPBUNDLE_PATH", &emmitted);
      }
  
    if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
      {
--- 965,991 ----
        {
        cmSystemTools::ConvertToUnixSlashes(env);
!       this->AddPathInternal(env, EnvPath);
        }
  
!     this->AddEnvPath("CMAKE_PREFIX_PATH");
!     this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
!     this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
      }
+ }
  
+ //----------------------------------------------------------------------------
+ void cmFindPackageCommand::AddPrefixesCMakeVariable()
+ {
    if(!this->NoCMakePath && !this->NoDefaultPath)
      {
!     this->AddCMakePath("CMAKE_PREFIX_PATH");
!     this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
!     this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
      }
+ }
  
+ //----------------------------------------------------------------------------
+ void cmFindPackageCommand::AddPrefixesSystemEnvironment()
+ {
    if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
      {
***************
*** 992,1006 ****
           d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0)
          {
!         this->AddPathInternal(prefixes,
!                               cmSystemTools::GetFilenamePath(d),
!                               EnvPath, &emmitted);
          }
        else
          {
!         this->AddPathInternal(prefixes, d, EnvPath, &emmitted);
          }
        }
      }
  
    if(!this->NoBuilds && !this->NoDefaultPath)
      {
--- 1004,1020 ----
           d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0)
          {
!         this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath);
          }
        else
          {
!         this->AddPathInternal(d, EnvPath);
          }
        }
      }
+ }
  
+ //----------------------------------------------------------------------------
+ void cmFindPackageCommand::AddPrefixesBuilds()
+ {
    if(!this->NoBuilds && !this->NoDefaultPath)
      {
***************
*** 1018,1038 ****
           cmSystemTools::FileIsDirectory(f.c_str()))
          {
!         this->AddPathInternal(prefixes, f, FullPath, &emmitted);
          }
        }
      }
  
    if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
      {
!     this->AddCMakePath(prefixes, "CMAKE_SYSTEM_PREFIX_PATH", &emmitted);
!     this->AddCMakePath(prefixes, "CMAKE_SYSTEM_FRAMEWORK_PATH", &emmitted);
!     this->AddCMakePath(prefixes, "CMAKE_SYSTEM_APPBUNDLE_PATH", &emmitted);
      }
  
    if(!this->UserPaths.empty())
      {
      // Add paths specified by the caller.
!     this->AddPathsInternal(prefixes, this->UserPaths, CMakePath, &emmitted);
      }
  
    // Construct the final set of prefixes.
--- 1032,1066 ----
           cmSystemTools::FileIsDirectory(f.c_str()))
          {
!         this->AddPathInternal(f, FullPath);
          }
        }
      }
+ }
  
+ //----------------------------------------------------------------------------
+ void cmFindPackageCommand::AddPrefixesCMakeSystemVariable()
+ {
    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::AddPrefixesUser()
+ {
    if(!this->UserPaths.empty())
      {
      // Add paths specified by the caller.
!     this->AddPathsInternal(this->UserPaths, CMakePath);
      }
+ }
+ 
+ //----------------------------------------------------------------------------
+ void cmFindPackageCommand::ComputeFinalPrefixes()
+ {
+   std::vector<std::string>& prefixes = this->SearchPaths;
  
    // Construct the final set of prefixes.



More information about the Cmake-commits mailing list