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

This commit is contained in:
Bill Hoffman 2004-04-22 13:24:20 -04:00
parent 5ff05c35d1
commit d59e06595c
6 changed files with 15 additions and 7 deletions

View File

@ -87,7 +87,8 @@ public:
" FIND_LIBRARY(VAR libraryName [path1 path2 ...])\n" " FIND_LIBRARY(VAR libraryName [path1 path2 ...])\n"
"Find a library with the given name by searching in the specified " "Find a library with the given name by searching in the specified "
"paths. This is a short-hand signature for the command that is " "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); cmTypeMacro(cmFindLibraryCommand, cmCommand);

View File

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

View File

@ -81,7 +81,8 @@ public:
"<VAR> is created to store the result. If the file is not " "<VAR> is created to store the result. If the file is not "
"found, the result will be <VAR>-NOTFOUND. If DOC is specified " "found, the result will be <VAR>-NOTFOUND. If DOC is specified "
"then the next argument is treated as a documentation string for " "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); cmTypeMacro(cmFindPathCommand, cmCommand);

View File

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

View File

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

View File

@ -121,9 +121,10 @@ public:
static unsigned long FileLength(const char *filename); static unsigned long FileLength(const char *filename);
/** /**
* Add the paths from the environment variable PATH to the * 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. */ /** Read an environment variable. */
static const char* GetEnv(const char* key); static const char* GetEnv(const char* key);