From 953f9c717d158216fe97a8720914531f5ea80cec Mon Sep 17 00:00:00 2001
From: Bill Hoffman <bill.hoffman@kitware.com>
Date: Thu, 22 Apr 2004 13:24:20 -0400
Subject: [PATCH] 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

---
 SystemTools.cxx    | 8 ++++++--
 SystemTools.hxx.in | 5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/SystemTools.cxx b/SystemTools.cxx
index e041f06a..68542e48 100644
--- a/SystemTools.cxx
+++ b/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] != ':')
     {
diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in
index b892e2f6..b95eb478 100644
--- a/SystemTools.hxx.in
+++ b/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);
-- 
GitLab