[cmake-commits] alex committed cmFindBase.cxx 1.23 1.24 cmFindBase.h 1.11 1.12 cmFindLibraryCommand.cxx 1.43 1.44 cmFindPathCommand.cxx 1.35 1.36 cmFindProgramCommand.cxx 1.39 1.40

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Oct 26 09:55:42 EDT 2007


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

Modified Files:
	cmFindBase.cxx cmFindBase.h cmFindLibraryCommand.cxx 
	cmFindPathCommand.cxx cmFindProgramCommand.cxx 
Log Message:
ENH: add support for CMAKE_FIND_PREFIX_PATH as discussed with Brad.
CMAKE_FIND_PREFIX_PATH is both an environment variable and a cmake variable,
which is a list of base directories where FIND_PATH, FIND_FILE, FIND_PROGRAM
and FIND_LIBRARY will search in the respective subdirectories

Alex


Index: cmFindBase.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindBase.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cmFindBase.h	18 May 2007 12:49:06 -0000	1.11
+++ cmFindBase.h	26 Oct 2007 13:55:40 -0000	1.12
@@ -53,6 +53,8 @@
   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();

Index: cmFindBase.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindBase.cxx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmFindBase.cxx	8 Jun 2007 17:43:17 -0000	1.23
+++ cmFindBase.cxx	26 Oct 2007 13:55:40 -0000	1.24
@@ -83,6 +83,7 @@
     "1. Search cmake specific environment variables.  This "
     "can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n"
     ""
+    "   CMAKE_FIND_PREFIX_PATH/XXX_SUBDIR\n"
     "   CMAKE_FRAMEWORK_PATH\n"
     "   CMAKE_APPBUNDLE_PATH\n"
     "   CMAKE_XXX_PATH\n"
@@ -92,6 +93,7 @@
     "-DVAR=value.  This can be skipped if NO_CMAKE_PATH "
     "is passed.\n"
     ""
+    "   CMAKE_FIND_PREFIX_PATH/XXX_SUBDIR\n"
     "   CMAKE_FRAMEWORK_PATH\n"
     "   CMAKE_APPBUNDLE_PATH\n"
     "   CMAKE_XXX_PATH\n"
@@ -546,10 +548,15 @@
 
 void cmFindBase::AddEnvironmentVariables()
 { 
+  std::vector<std::string> paths;
+
+  std::vector<std::string> prefixPaths;
+  cmSystemTools::GetPath(prefixPaths, "CMAKE_FIND_PREFIX_PATH");
+  this->AddFindPrefix(paths, prefixPaths);
+
   std::string var = "CMAKE_";
   var += this->CMakePathName;
   var += "_PATH";
-  std::vector<std::string> paths;
   cmSystemTools::GetPath(paths, var.c_str());
   if(this->SearchAppBundleLast)
     {
@@ -559,7 +566,42 @@
     {
     cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH");
     }
-   this->AddPaths(paths);
+  this->AddPaths(paths);
+}
+
+void cmFindBase::AddFindPrefix(std::vector<std::string>& dest, 
+                               const std::vector<std::string>& src)
+{
+  // default for programs
+  std::string subdir = "/bin";
+
+  if (this->CMakePathName == "INCLUDE")
+    {
+    subdir = "/include";
+    }
+  else if (this->CMakePathName == "LIBRARY")
+    {
+    subdir = "/lib";
+    }
+  else if (this->CMakePathName == "FRAMEWORK")
+    {
+    subdir = "";  // ? what to do for frameworks ?
+    }
+
+  for (std::vector<std::string>::const_iterator it = src.begin();
+       it != src.end();
+       ++it)
+    {
+    std::string dirWithSubdir = it->c_str();
+    dirWithSubdir += subdir;
+    dest.push_back(dirWithSubdir);
+    if (subdir == "/bin")
+      {
+      dirWithSubdir = it->c_str();
+      dirWithSubdir += "/sbin";
+      dest.push_back(dirWithSubdir);
+      }
+    }
 }
 
 void cmFindBase::AddFrameWorkPaths()
@@ -644,6 +686,15 @@
   var += this->CMakePathName;
   var += "_PATH";
   std::vector<std::string> paths;
+
+  if(const char* prefixPath = 
+      this->Makefile->GetDefinition("CMAKE_FIND_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);

Index: cmFindProgramCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindProgramCommand.cxx,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- cmFindProgramCommand.cxx	10 Oct 2007 15:47:43 -0000	1.39
+++ cmFindProgramCommand.cxx	26 Oct 2007 13:55:40 -0000	1.40
@@ -38,6 +38,8 @@
   cmSystemTools::ReplaceString(this->GenericDocumentation,
                                "SEARCH_XXX", "program");
   cmSystemTools::ReplaceString(this->GenericDocumentation,
+                               "XXX_SUBDIR", "[s]bin");
+  cmSystemTools::ReplaceString(this->GenericDocumentation,
                                "CMAKE_FIND_ROOT_PATH_MODE_XXX", 
                                "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM");
 }

Index: cmFindLibraryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindLibraryCommand.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- cmFindLibraryCommand.cxx	10 Oct 2007 15:47:43 -0000	1.43
+++ cmFindLibraryCommand.cxx	26 Oct 2007 13:55:40 -0000	1.44
@@ -33,6 +33,8 @@
   cmSystemTools::ReplaceString(this->GenericDocumentation,
                                "SEARCH_XXX", "library");
   cmSystemTools::ReplaceString(this->GenericDocumentation,
+                               "XXX_SUBDIR", "lib");
+  cmSystemTools::ReplaceString(this->GenericDocumentation,
                                "CMAKE_FIND_ROOT_PATH_MODE_XXX", 
                                "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY");
 

Index: cmFindPathCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPathCommand.cxx,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- cmFindPathCommand.cxx	10 Oct 2007 15:47:43 -0000	1.35
+++ cmFindPathCommand.cxx	26 Oct 2007 13:55:40 -0000	1.36
@@ -37,6 +37,8 @@
   cmSystemTools::ReplaceString(this->GenericDocumentation,
                                "SEARCH_XXX", "file in a directory");
   cmSystemTools::ReplaceString(this->GenericDocumentation,
+                               "XXX_SUBDIR", "include");
+  cmSystemTools::ReplaceString(this->GenericDocumentation,
                                "CMAKE_FIND_ROOT_PATH_MODE_XXX", 
                                "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE");
 



More information about the Cmake-commits mailing list