[Cmake-commits] [cmake-commits] king committed cmFindBase.cxx 1.46 1.47 cmFindBase.h 1.15 1.16 cmFindCommon.cxx 1.3 1.4 cmFindCommon.h 1.3 1.4 cmFindPackageCommand.cxx 1.38 1.39 cmFindPackageCommand.h 1.20 1.21

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jun 9 15:09:01 EDT 2008


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

Modified Files:
	cmFindBase.cxx cmFindBase.h cmFindCommon.cxx cmFindCommon.h 
	cmFindPackageCommand.cxx cmFindPackageCommand.h 
Log Message:
ENH: Add HINTS option to find_* commands.

  - Hints are searched after user locations but before system locations
  - The HINTS option should have paths provided by system introspection
  - The PATHS option should have paths that are hard-coded guesses


Index: cmFindBase.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindBase.cxx,v
retrieving revision 1.46
retrieving revision 1.47
diff -C 2 -d -r1.46 -r1.47
*** cmFindBase.cxx	9 Jun 2008 15:58:27 -0000	1.46
--- cmFindBase.cxx	9 Jun 2008 19:08:58 -0000	1.47
***************
*** 31,34 ****
--- 31,35 ----
      "             <VAR>\n"
      "             name | NAMES name1 [name2 ...]\n"
+     "             [HINTS path1 [path2 ... ENV var]]\n"
      "             [PATHS path1 [path2 ... ENV var]]\n"
      "             [PATH_SUFFIXES suffix1 [suffix2 ...]]\n"
***************
*** 56,60 ****
      "after the NAMES argument.   Additional search locations "
      "can be specified after the PATHS argument.  If ENV var is "
!     "found in the PATHS section the environment variable var "
      "will be read and converted from a system environment variable to "
      "a cmake style list of paths.  For example ENV PATH would be a way "
--- 57,61 ----
      "after the NAMES argument.   Additional search locations "
      "can be specified after the PATHS argument.  If ENV var is "
!     "found in the HINTS or PATHS section the environment variable var "
      "will be read and converted from a system environment variable to "
      "a cmake style list of paths.  For example ENV PATH would be a way "
***************
*** 81,89 ****
      "   CMAKE_XXX_PATH\n"
      "   CMAKE_XXX_MAC_PATH\n"
!     "3. Search the standard system environment variables. "
      "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n"
      "   PATH\n"
      "   XXX_SYSTEM\n"  // replace with "", LIB, or INCLUDE
!     "4. Search cmake variables defined in the Platform files "
      "for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH "
      "is passed.\n"
--- 82,94 ----
      "   CMAKE_XXX_PATH\n"
      "   CMAKE_XXX_MAC_PATH\n"
!     "3. Search the paths specified by the HINTS option.  "
!     "These should be paths computed by system introspection, such as a "
!     "hint provided by the location of another item already found.  "
!     "Hard-coded guesses should be specified with the PATHS option.\n"
!     "4. Search the standard system environment variables. "
      "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n"
      "   PATH\n"
      "   XXX_SYSTEM\n"  // replace with "", LIB, or INCLUDE
!     "5. Search cmake variables defined in the Platform files "
      "for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH "
      "is passed.\n"
***************
*** 91,96 ****
      "   CMAKE_SYSTEM_XXX_PATH\n"
      "   CMAKE_SYSTEM_XXX_MAC_PATH\n"
!     "5. Search the paths specified after PATHS or in the short-hand version "
!     "of the command.\n"
      ;
    this->GenericDocumentation += this->GenericDocumentationMacPolicy;
--- 96,102 ----
      "   CMAKE_SYSTEM_XXX_PATH\n"
      "   CMAKE_SYSTEM_XXX_MAC_PATH\n"
!     "6. Search the paths specified by the PATHS option "
!     "or in the short-hand version of the command.  "
!     "These are typically hard-coded guesses.\n"
      ;
    this->GenericDocumentation += this->GenericDocumentationMacPolicy;
***************
*** 162,224 ****
    this->SelectDefaultMacMode();
  
-   std::string doc;
-   bool doingNames = true; // assume it starts with a name
-   bool doingPaths = false;
-   bool doingPathSuf = false;
    bool newStyle = false;
!   
    for (unsigned int j = 1; j < args.size(); ++j)
      {
      if(args[j] == "NAMES")
        {
!       doingNames = true;
        newStyle = true;
-       doingPathSuf = false;
-       doingPaths = false;
        }
      else if (args[j] == "PATHS")
        {
!       doingPaths = true;
        newStyle = true;
-       doingNames = false;
-       doingPathSuf = false;
        }
      else if (args[j] == "PATH_SUFFIXES")
        {
        compatibility = false;
-       doingPathSuf = true;
        newStyle = true;
-       doingNames = false;
-       doingPaths = false;
        }
      else if (args[j] == "NO_SYSTEM_PATH")
        {
!       doingPaths = false;
!       doingPathSuf = false;
!       doingNames = false;
        this->NoDefaultPath = true;
        }
      else if (this->CheckCommonArgument(args[j]))
        {
        compatibility = false;
-       doingPaths = false;
-       doingPathSuf = false;
-       doingNames = false;
        newStyle = true;
        }
!     else
        {
!       if(doingNames)
!         {
!         this->Names.push_back(args[j]);
!         }
!       else if(doingPaths)
!         {
!         this->AddUserPath(args[j]);
!         }
!       else if(doingPathSuf)
!         {
!         this->AddPathSuffix(args[j]);
!         }
        }
      }
--- 168,224 ----
    this->SelectDefaultMacMode();
  
    bool newStyle = false;
!   enum Doing { DoingNone, DoingNames, DoingPaths, DoingPathSuffixes,
!                DoingHints };
!   Doing doing = DoingNames; // assume it starts with a name
    for (unsigned int j = 1; j < args.size(); ++j)
      {
      if(args[j] == "NAMES")
        {
!       doing = DoingNames;
        newStyle = true;
        }
      else if (args[j] == "PATHS")
        {
!       doing = DoingPaths;
!       newStyle = true;
!       }
!     else if (args[j] == "HINTS")
!       {
!       doing = DoingHints;
        newStyle = true;
        }
      else if (args[j] == "PATH_SUFFIXES")
        {
+       doing = DoingPathSuffixes;
        compatibility = false;
        newStyle = true;
        }
      else if (args[j] == "NO_SYSTEM_PATH")
        {
!       doing = DoingNone;
        this->NoDefaultPath = true;
        }
      else if (this->CheckCommonArgument(args[j]))
        {
+       doing = DoingNone;
        compatibility = false;
        newStyle = true;
        }
!     else if(doing == DoingNames)
        {
!       this->Names.push_back(args[j]);
!       }
!     else if(doing == DoingPaths)
!       {
!       this->AddUserPath(args[j], this->UserPaths);
!       }
!     else if(doing == DoingHints)
!       {
!       this->AddUserPath(args[j], this->UserHints);
!       }
!     else if(doing == DoingPathSuffixes)
!       {
!       this->AddPathSuffix(args[j]);
        }
      }
***************
*** 267,271 ****
      for(unsigned int j = 2; j < args.size(); ++j)
        {
!       this->AddUserPath(args[j]);
        }
      }
--- 267,271 ----
      for(unsigned int j = 2; j < args.size(); ++j)
        {
!       this->AddUserPath(args[j], this->UserPaths);
        }
      }
***************
*** 285,293 ****
    this->AddCMakeEnvironmentPath();
    this->AddCMakeVariablePath();
    this->AddSystemEnvironmentPath();
    this->AddCMakeSystemVariablePath();
! 
!   // Add paths specified by the caller.
!   this->AddPathsInternal(this->UserPaths, CMakePath);
  
    // Add suffixes and clean up paths.
--- 285,292 ----
    this->AddCMakeEnvironmentPath();
    this->AddCMakeVariablePath();
+   this->AddUserHintsPath();
    this->AddSystemEnvironmentPath();
    this->AddCMakeSystemVariablePath();
!   this->AddUserGuessPath();
  
    // Add suffixes and clean up paths.
***************
*** 446,449 ****
--- 445,460 ----
  
  //----------------------------------------------------------------------------
+ void cmFindBase::AddUserHintsPath()
+ {
+   this->AddPathsInternal(this->UserHints, CMakePath);
+ }
+ 
+ //----------------------------------------------------------------------------
+ void cmFindBase::AddUserGuessPath()
+ {
+   this->AddPathsInternal(this->UserPaths, CMakePath);
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmFindBase::AddPathSuffixes()
  {

Index: cmFindCommon.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindCommon.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** cmFindCommon.cxx	9 Jun 2008 15:57:54 -0000	1.3
--- cmFindCommon.cxx	9 Jun 2008 19:08:59 -0000	1.4
***************
*** 77,88 ****
      "is used then only the re-rooted directories will be searched.\n";
    this->GenericDocumentationPathsOrder =
!     "The reason the paths listed in the call to the command are searched "
!     "last is that most users of CMake would expect things to be found "
!     "first in the locations specified by their environment.  Projects may "
!     "override this behavior by simply calling the command twice:\n"
      "   FIND_XXX(FIND_ARGS_XXX PATHS paths... NO_DEFAULT_PATH)\n"
      "   FIND_XXX(FIND_ARGS_XXX)\n"
!     "Once one of these calls succeeds the result variable will be set "
!     "and stored in the cache so that neither call will search again.";
  }
  
--- 77,88 ----
      "is used then only the re-rooted directories will be searched.\n";
    this->GenericDocumentationPathsOrder =
!     "The default search order is designed to be most-specific to "
!     "least-specific for common use cases.  "
!     "Projects may override the order by simply calling the command "
!     "multiple times and using the NO_* options:\n"
      "   FIND_XXX(FIND_ARGS_XXX PATHS paths... NO_DEFAULT_PATH)\n"
      "   FIND_XXX(FIND_ARGS_XXX)\n"
!     "Once one of the calls succeeds the result variable will be set "
!     "and stored in the cache so that no call will search again.";
  }
  
***************
*** 323,327 ****
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddUserPath(std::string const& p)
  {
    // We should view the registry as the target application would view
--- 323,328 ----
  
  //----------------------------------------------------------------------------
! void cmFindCommon::AddUserPath(std::string const& p,
!                                std::vector<std::string>& paths)
  {
    // We should view the registry as the target application would view
***************
*** 342,346 ****
    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
--- 343,347 ----
    std::string expanded = p;
    cmSystemTools::ExpandRegistryValues(expanded, view);
!   cmSystemTools::GlobDirs(expanded.c_str(), paths);
  
    // Executables can be either 32-bit or 64-bit, so expand using the
***************
*** 350,354 ****
      expanded = p;
      cmSystemTools::ExpandRegistryValues(expanded, other_view);
!     cmSystemTools::GlobDirs(expanded.c_str(), this->UserPaths);
      }
  }
--- 351,355 ----
      expanded = p;
      cmSystemTools::ExpandRegistryValues(expanded, other_view);
!     cmSystemTools::GlobDirs(expanded.c_str(), paths);
      }
  }

Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmFindPackageCommand.h	5 Jun 2008 22:20:16 -0000	1.20
--- cmFindPackageCommand.h	9 Jun 2008 19:08:59 -0000	1.21
***************
*** 89,93 ****
    void AddPrefixesBuilds();
    void AddPrefixesCMakeSystemVariable();
!   void AddPrefixesUser();
    void ComputeFinalPrefixes();
    bool SearchDirectory(std::string const& dir);
--- 89,94 ----
    void AddPrefixesBuilds();
    void AddPrefixesCMakeSystemVariable();
!   void AddPrefixesUserGuess();
!   void AddPrefixesUserHints();
    void ComputeFinalPrefixes();
    bool SearchDirectory(std::string const& dir);

Index: cmFindCommon.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindCommon.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** cmFindCommon.h	9 Jun 2008 15:57:55 -0000	1.3
--- cmFindCommon.h	9 Jun 2008 19:08:59 -0000	1.4
***************
*** 59,63 ****
    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);
--- 59,64 ----
    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 char* variable);
    void AddEnvPath(const char* variable);
***************
*** 74,77 ****
--- 75,79 ----
    std::vector<std::string> SearchPathSuffixes;
    std::vector<std::string> UserPaths;
+   std::vector<std::string> UserHints;
    std::vector<std::string> SearchPaths;
    std::set<cmStdString> SearchPathsEmitted;

Index: cmFindBase.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindBase.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C 2 -d -r1.15 -r1.16
*** cmFindBase.h	9 Jun 2008 15:58:28 -0000	1.15
--- cmFindBase.h	9 Jun 2008 19:08:58 -0000	1.16
***************
*** 67,70 ****
--- 67,72 ----
    void AddSystemEnvironmentPath();
    void AddCMakeSystemVariablePath();
+   void AddUserHintsPath();
+   void AddUserGuessPath();
  
    // Helpers.

Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.38
retrieving revision 1.39
diff -C 2 -d -r1.38 -r1.39
*** cmFindPackageCommand.cxx	9 Jun 2008 15:57:56 -0000	1.38
--- cmFindPackageCommand.cxx	9 Jun 2008 19:08:59 -0000	1.39
***************
*** 113,116 ****
--- 113,117 ----
      "               [NAMES name1 [name2 ...]]\n"
      "               [CONFIGS config1 [config2 ...]]\n"
+     "               [HINTS path1 [path2 ... ]]\n"
      "               [PATHS path1 [path2 ... ]]\n"
      "               [PATH_SUFFIXES suffix1 [suffix2 ...]]\n"
***************
*** 252,265 ****
      "   CMAKE_FRAMEWORK_PATH\n"
      "   CMAKE_APPBUNDLE_PATH\n"
!     "3. Search the standard system environment variables. "
      "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is passed.  "
      "Path entries ending in \"/bin\" or \"/sbin\" are automatically "
      "converted to their parent directories.\n"
      "   PATH\n"
!     "4. Search project build trees recently configured in a CMake GUI.  "
      "This can be skipped if NO_CMAKE_BUILDS_PATH is passed.  "
      "It is intended for the case when a user is building multiple "
      "dependent projects one after another.\n"
!     "5. Search cmake variables defined in the Platform files "
      "for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH "
      "is passed.\n"
--- 253,270 ----
      "   CMAKE_FRAMEWORK_PATH\n"
      "   CMAKE_APPBUNDLE_PATH\n"
!     "3. Search paths specified by the HINTS option.  "
!     "These should be paths computed by system introspection, such as a "
!     "hint provided by the location of another item already found.  "
!     "Hard-coded guesses should be specified with the PATHS option.\n"
!     "4. Search the standard system environment variables. "
      "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is passed.  "
      "Path entries ending in \"/bin\" or \"/sbin\" are automatically "
      "converted to their parent directories.\n"
      "   PATH\n"
!     "5. Search project build trees recently configured in a CMake GUI.  "
      "This can be skipped if NO_CMAKE_BUILDS_PATH is passed.  "
      "It is intended for the case when a user is building multiple "
      "dependent projects one after another.\n"
!     "6. Search cmake variables defined in the Platform files "
      "for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH "
      "is passed.\n"
***************
*** 267,271 ****
      "   CMAKE_SYSTEM_FRAMEWORK_PATH\n"
      "   CMAKE_SYSTEM_APPBUNDLE_PATH\n"
!     "6. Search paths specified by the PATHS option.\n"
      ;
    this->CommandDocumentation += this->GenericDocumentationMacPolicy;
--- 272,277 ----
      "   CMAKE_SYSTEM_FRAMEWORK_PATH\n"
      "   CMAKE_SYSTEM_APPBUNDLE_PATH\n"
!     "7. Search paths specified by the PATHS option.  "
!     "These are typically hard-coded guesses.\n"
      ;
    this->CommandDocumentation += this->GenericDocumentationMacPolicy;
***************
*** 314,318 ****
    // Parse the arguments.
    enum Doing { DoingNone, DoingComponents, DoingNames, DoingPaths,
!                DoingPathSuffixes, DoingConfigs };
    Doing doing = DoingNone;
    cmsys::RegularExpression version("^[0-9.]+$");
--- 320,324 ----
    // Parse the arguments.
    enum Doing { DoingNone, DoingComponents, DoingNames, DoingPaths,
!                DoingPathSuffixes, DoingConfigs, DoingHints };
    Doing doing = DoingNone;
    cmsys::RegularExpression version("^[0-9.]+$");
***************
*** 358,361 ****
--- 364,373 ----
        doing = DoingPaths;
        }
+     else if(args[i] == "HINTS")
+       {
+       this->NoModule = true;
+       this->Compatibility_1_6 = false;
+       doing = DoingHints;
+       }
      else if(args[i] == "PATH_SUFFIXES")
        {
***************
*** 401,405 ****
      else if(doing == DoingPaths)
        {
!       this->AddUserPath(args[i]);
        }
      else if(doing == DoingPathSuffixes)
--- 413,421 ----
      else if(doing == DoingPaths)
        {
!       this->AddUserPath(args[i], this->UserPaths);
!       }
!     else if(doing == DoingHints)
!       {
!       this->AddUserPath(args[i], this->UserHints);
        }
      else if(doing == DoingPathSuffixes)
***************
*** 947,954 ****
    this->AddPrefixesCMakeEnvironment();
    this->AddPrefixesCMakeVariable();
    this->AddPrefixesSystemEnvironment();
    this->AddPrefixesBuilds();
    this->AddPrefixesCMakeSystemVariable();
!   this->AddPrefixesUser();
    this->ComputeFinalPrefixes();
  }
--- 963,971 ----
    this->AddPrefixesCMakeEnvironment();
    this->AddPrefixesCMakeVariable();
+   this->AddPrefixesUserHints();
    this->AddPrefixesSystemEnvironment();
    this->AddPrefixesBuilds();
    this->AddPrefixesCMakeSystemVariable();
!   this->AddPrefixesUserGuess();
    this->ComputeFinalPrefixes();
  }
***************
*** 1050,1060 ****
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::AddPrefixesUser()
  {
!   if(!this->UserPaths.empty())
!     {
!     // Add paths specified by the caller.
!     this->AddPathsInternal(this->UserPaths, CMakePath);
!     }
  }
  
--- 1067,1081 ----
  
  //----------------------------------------------------------------------------
! void cmFindPackageCommand::AddPrefixesUserGuess()
  {
!   // Add guesses specified by the caller.
!   this->AddPathsInternal(this->UserPaths, CMakePath);
! }
! 
! //----------------------------------------------------------------------------
! void cmFindPackageCommand::AddPrefixesUserHints()
! {
!   // Add hints specified by the caller.
!   this->AddPathsInternal(this->UserHints, CMakePath);
  }
  



More information about the Cmake-commits mailing list