Explorar el Código

BUG: fix for 301 CMAKE_LIBRARY_PATH and CMAKE_INCLUDE_PATH env vars now used in FIND_LIBRARY and FIND_PATH in addtion to and before PATH

Bill Hoffman hace 21 años
padre
commit
d59e06595c

+ 2 - 1
Source/cmFindLibraryCommand.h

@@ -87,7 +87,8 @@ public:
       "  FIND_LIBRARY(VAR libraryName [path1 path2 ...])\n"
       "Find a library with the given name by searching in the specified "
       "paths.  This is a short-hand signature for the command that is "
-      "sufficient in many cases.";
+      "sufficient in many cases.  The environment variable CMAKE_LIBRARY_PATH "
+      "is searched as well as the PATH variable.\n";
     }
   
   cmTypeMacro(cmFindLibraryCommand, cmCommand);

+ 1 - 1
Source/cmFindPathCommand.cxx

@@ -75,7 +75,7 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
     // Glob the entry in case of wildcards.
     cmSystemTools::GlobDirs(exp.c_str(), path);
     }
-
+  cmSystemTools::GetPath(path, "CMAKE_INCLUDE_PATH");
   // add the standard path
   cmSystemTools::GetPath(path);
   unsigned int k;

+ 2 - 1
Source/cmFindPathCommand.h

@@ -81,7 +81,8 @@ public:
       "<VAR> is created to store the result.  If the file is not "
       "found, the result will be <VAR>-NOTFOUND.  If DOC is specified "
       "then the next argument is treated as a documentation string for "
-      "the cache entry <VAR>.\n";
+      "the cache entry <VAR>.  The environment variable CMAKE_INCLUDE_PATH "
+      "is searched as well as the PATH variable.\n";
     }
   
   cmTypeMacro(cmFindPathCommand, cmCommand);

+ 1 - 0
Source/cmMakefile.cxx

@@ -2133,6 +2133,7 @@ std::string cmMakefile::FindLibrary(const char* name,
   
   // Add the system search path to our path.
   std::vector<std::string> path = userPaths;
+  cmSystemTools::GetPath(path, "CMAKE_LIBRARY_PATH");
   cmSystemTools::GetPath(path);
 
   // Add some lib directories specific to compilers, depending on the

+ 6 - 2
Source/kwsys/SystemTools.cxx

@@ -158,14 +158,18 @@ SystemTools::GetTime(void)
 }
 
 // adds the elements of the env variable path to the arg passed in
-void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path)
+void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
   const char* pathSep = ";";
 #else
   const char* pathSep = ":";
 #endif
-  kwsys_stl::string pathEnv = getenv("PATH");
+  if(!env)
+    {
+    env = "PATH";
+    }
+  kwsys_stl::string pathEnv = getenv(env);
   // A hack to make the below algorithm work.  
   if(pathEnv[pathEnv.length()-1] != ':')
     {

+ 3 - 2
Source/kwsys/SystemTools.hxx.in

@@ -121,9 +121,10 @@ public:
   static unsigned long FileLength(const char *filename);
   /**
    *  Add the paths from the environment variable PATH to the 
-   *  string vector passed in.
+   *  string vector passed in.  If env is set then the value
+   *  of env will be used instead of PATH.
    */
-  static void GetPath(kwsys_stl::vector<kwsys_stl::string>& path);
+  static void GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env=0);
 
   /** Read an environment variable.  */
   static const char* GetEnv(const char* key);