BUG: fix problem with path suffix and mac frameworks and find stuff, showed up in FindPythonLibs.cmake

This commit is contained in:
Bill Hoffman 2006-12-28 15:31:47 -05:00
parent f6c2972956
commit 255a4b966e
2 changed files with 56 additions and 30 deletions

View File

@ -444,14 +444,13 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
this->AddFrameWorkPaths(); this->AddFrameWorkPaths();
} }
} }
std::vector<std::string> paths;
// add the paths specified in the FIND_* call // add the paths specified in the FIND_* call
for(unsigned int i =0; i < userPaths.size(); ++i) for(unsigned int i =0; i < userPaths.size(); ++i)
{ {
this->SearchPaths.push_back(userPaths[i]); paths.push_back(userPaths[i]);
} }
this->AddPaths(paths);
// clean things up
this->ExpandRegistryAndCleanPath();
} }
void cmFindBase::AddEnvironmentVairables() void cmFindBase::AddEnvironmentVairables()
@ -459,16 +458,17 @@ void cmFindBase::AddEnvironmentVairables()
std::string var = "CMAKE_"; std::string var = "CMAKE_";
var += this->CMakePathName; var += this->CMakePathName;
var += "_PATH"; var += "_PATH";
cmSystemTools::GetPath(this->SearchPaths, var.c_str()); std::vector<std::string> paths;
cmSystemTools::GetPath(paths, var.c_str());
if(this->SearchAppBundleLast) if(this->SearchAppBundleLast)
{ {
cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH"); cmSystemTools::GetPath(paths, "CMAKE_APPBUNDLE_PATH");
} }
if(this->SearchFrameworkLast) if(this->SearchFrameworkLast)
{ {
cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH"); cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH");
} }
this->AddPaths(paths);
} }
void cmFindBase::AddFrameWorkPaths() void cmFindBase::AddFrameWorkPaths()
@ -477,10 +477,11 @@ void cmFindBase::AddFrameWorkPaths()
{ {
return; return;
} }
std::vector<std::string> paths;
// first environment variables // first environment variables
if(!this->NoCMakeEnvironmentPath) if(!this->NoCMakeEnvironmentPath)
{ {
cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH"); cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH");
} }
// add cmake variables // add cmake variables
if(!this->NoCMakePath) if(!this->NoCMakePath)
@ -488,7 +489,7 @@ void cmFindBase::AddFrameWorkPaths()
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
// AddCMakeSystemVariables // AddCMakeSystemVariables
@ -497,9 +498,20 @@ void cmFindBase::AddFrameWorkPaths()
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH")) this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
this->AddPaths(paths);
}
void cmFindBase::AddPaths(std::vector<std::string> & paths)
{
// add suffixes and clean up paths
this->ExpandRegistryAndCleanPath(paths);
// add the paths to the search paths
this->SearchPaths.insert(this->SearchPaths.end(),
paths.begin(),
paths.end());
} }
void cmFindBase::AddAppBundlePaths() void cmFindBase::AddAppBundlePaths()
@ -508,10 +520,11 @@ void cmFindBase::AddAppBundlePaths()
{ {
return; return;
} }
std::vector<std::string> paths;
// first environment variables // first environment variables
if(!this->NoCMakeEnvironmentPath) if(!this->NoCMakeEnvironmentPath)
{ {
cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH"); cmSystemTools::GetPath(paths, "CMAKE_APPBUNDLE_PATH");
} }
// add cmake variables // add cmake variables
if(!this->NoCMakePath) if(!this->NoCMakePath)
@ -519,7 +532,7 @@ void cmFindBase::AddAppBundlePaths()
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH")) this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
// AddCMakeSystemVariables // AddCMakeSystemVariables
@ -528,9 +541,10 @@ void cmFindBase::AddAppBundlePaths()
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH")) this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
this->AddPaths(paths);
} }
void cmFindBase::AddCMakeVairables() void cmFindBase::AddCMakeVairables()
@ -538,16 +552,17 @@ void cmFindBase::AddCMakeVairables()
std::string var = "CMAKE_"; std::string var = "CMAKE_";
var += this->CMakePathName; var += this->CMakePathName;
var += "_PATH"; var += "_PATH";
std::vector<std::string> paths;
if(const char* path = this->Makefile->GetDefinition(var.c_str())) if(const char* path = this->Makefile->GetDefinition(var.c_str()))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
if(this->SearchAppBundleLast) if(this->SearchAppBundleLast)
{ {
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH")) this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
if(this->SearchFrameworkLast) if(this->SearchFrameworkLast)
@ -555,20 +570,23 @@ void cmFindBase::AddCMakeVairables()
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
this->AddPaths(paths);
} }
void cmFindBase::AddSystemEnvironmentVairables() void cmFindBase::AddSystemEnvironmentVairables()
{ {
// Add LIB or INCLUDE // Add LIB or INCLUDE
std::vector<std::string> paths;
if(this->EnvironmentPath.size()) if(this->EnvironmentPath.size())
{ {
cmSystemTools::GetPath(this->SearchPaths, this->EnvironmentPath.c_str()); cmSystemTools::GetPath(paths, this->EnvironmentPath.c_str());
} }
// Add PATH // Add PATH
cmSystemTools::GetPath(this->SearchPaths); cmSystemTools::GetPath(paths);
this->AddPaths(paths);
} }
void cmFindBase::AddCMakeSystemVariables() void cmFindBase::AddCMakeSystemVariables()
@ -576,16 +594,17 @@ void cmFindBase::AddCMakeSystemVariables()
std::string var = "CMAKE_SYSTEM_"; std::string var = "CMAKE_SYSTEM_";
var += this->CMakePathName; var += this->CMakePathName;
var += "_PATH"; var += "_PATH";
std::vector<std::string> paths;
if(const char* path = this->Makefile->GetDefinition(var.c_str())) if(const char* path = this->Makefile->GetDefinition(var.c_str()))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
if(this->SearchAppBundleLast) if(this->SearchAppBundleLast)
{ {
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH")) this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
if(this->SearchFrameworkLast) if(this->SearchFrameworkLast)
@ -593,23 +612,28 @@ void cmFindBase::AddCMakeSystemVariables()
if(const char* path = if(const char* path =
this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH")) this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH"))
{ {
cmSystemTools::ExpandListArgument(path, this->SearchPaths); cmSystemTools::ExpandListArgument(path, paths);
} }
} }
this->AddPaths(paths);
} }
void cmFindBase::ExpandRegistryAndCleanPath() void cmFindBase::ExpandRegistryAndCleanPath(std::vector<std::string>& paths)
{ {
std::vector<std::string> finalPath; std::vector<std::string> finalPath;
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
for(i = this->SearchPaths.begin(); // glob and expand registry stuff from paths and put
i != this->SearchPaths.end(); ++i) // into finalPath
for(i = paths.begin();
i != paths.end(); ++i)
{ {
cmSystemTools::ExpandRegistryValues(*i); cmSystemTools::ExpandRegistryValues(*i);
cmSystemTools::GlobDirs(i->c_str(), finalPath); cmSystemTools::GlobDirs(i->c_str(), finalPath);
} }
this->SearchPaths.clear(); // clear the path
// convert all paths to unix slashes paths.clear();
// convert all paths to unix slashes and add search path suffixes
// if there are any
for(i = finalPath.begin(); for(i = finalPath.begin();
i != finalPath.end(); ++i) i != finalPath.end(); ++i)
{ {
@ -623,7 +647,7 @@ void cmFindBase::ExpandRegistryAndCleanPath()
std::string p = *i + std::string("/") + *j; std::string p = *i + std::string("/") + *j;
// add to all paths because the search path may be modified // add to all paths because the search path may be modified
// later with lib being replaced for lib64 which may exist // later with lib being replaced for lib64 which may exist
this->SearchPaths.push_back(p); paths.push_back(p);
} }
} }
// now put the path without the path suffixes in the SearchPaths // now put the path without the path suffixes in the SearchPaths
@ -632,7 +656,7 @@ void cmFindBase::ExpandRegistryAndCleanPath()
{ {
// put all search paths in because it may later be replaced // put all search paths in because it may later be replaced
// by lib64 stuff fixes bug 4009 // by lib64 stuff fixes bug 4009
this->SearchPaths.push_back(*i); paths.push_back(*i);
} }
} }

View File

@ -42,13 +42,15 @@ public:
protected: protected:
void PrintFindStuff(); void PrintFindStuff();
void ExpandPaths(std::vector<std::string> userPaths); void ExpandPaths(std::vector<std::string> userPaths);
// add to the SearchPaths
void AddPaths(std::vector<std::string>& paths);
void AddFrameWorkPaths(); void AddFrameWorkPaths();
void AddAppBundlePaths(); void AddAppBundlePaths();
void AddEnvironmentVairables(); void AddEnvironmentVairables();
void AddCMakeVairables(); void AddCMakeVairables();
void AddSystemEnvironmentVairables(); void AddSystemEnvironmentVairables();
void AddCMakeSystemVariables(); void AddCMakeSystemVariables();
void ExpandRegistryAndCleanPath(); void ExpandRegistryAndCleanPath(std::vector<std::string>& paths);
// see if the VariableName is already set in the cache, // see if the VariableName is already set in the cache,
// also copy the documentation from the cache to VariableDocumentation // also copy the documentation from the cache to VariableDocumentation
// if it has documentation in the cache // if it has documentation in the cache