From 255a4b966e0717ef61f1a6e364b141fccd0f1fb8 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 28 Dec 2006 15:31:47 -0500 Subject: [PATCH] BUG: fix problem with path suffix and mac frameworks and find stuff, showed up in FindPythonLibs.cmake --- Source/cmFindBase.cxx | 82 ++++++++++++++++++++++++++++--------------- Source/cmFindBase.h | 4 ++- 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 9c14e8ebd..d2ac606c1 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -444,14 +444,13 @@ void cmFindBase::ExpandPaths(std::vector userPaths) this->AddFrameWorkPaths(); } } + std::vector paths; // add the paths specified in the FIND_* call for(unsigned int i =0; i < userPaths.size(); ++i) { - this->SearchPaths.push_back(userPaths[i]); + paths.push_back(userPaths[i]); } - - // clean things up - this->ExpandRegistryAndCleanPath(); + this->AddPaths(paths); } void cmFindBase::AddEnvironmentVairables() @@ -459,16 +458,17 @@ void cmFindBase::AddEnvironmentVairables() std::string var = "CMAKE_"; var += this->CMakePathName; var += "_PATH"; - cmSystemTools::GetPath(this->SearchPaths, var.c_str()); + std::vector paths; + cmSystemTools::GetPath(paths, var.c_str()); if(this->SearchAppBundleLast) { - cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH"); + cmSystemTools::GetPath(paths, "CMAKE_APPBUNDLE_PATH"); } if(this->SearchFrameworkLast) { - cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH"); + cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH"); } - + this->AddPaths(paths); } void cmFindBase::AddFrameWorkPaths() @@ -477,10 +477,11 @@ void cmFindBase::AddFrameWorkPaths() { return; } + std::vector paths; // first environment variables if(!this->NoCMakeEnvironmentPath) { - cmSystemTools::GetPath(this->SearchPaths, "CMAKE_FRAMEWORK_PATH"); + cmSystemTools::GetPath(paths, "CMAKE_FRAMEWORK_PATH"); } // add cmake variables if(!this->NoCMakePath) @@ -488,7 +489,7 @@ void cmFindBase::AddFrameWorkPaths() if(const char* path = this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } } // AddCMakeSystemVariables @@ -497,9 +498,20 @@ void cmFindBase::AddFrameWorkPaths() if(const char* 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 & 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() @@ -508,10 +520,11 @@ void cmFindBase::AddAppBundlePaths() { return; } + std::vector paths; // first environment variables if(!this->NoCMakeEnvironmentPath) { - cmSystemTools::GetPath(this->SearchPaths, "CMAKE_APPBUNDLE_PATH"); + cmSystemTools::GetPath(paths, "CMAKE_APPBUNDLE_PATH"); } // add cmake variables if(!this->NoCMakePath) @@ -519,7 +532,7 @@ void cmFindBase::AddAppBundlePaths() if(const char* path = this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH")) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } } // AddCMakeSystemVariables @@ -528,9 +541,10 @@ void cmFindBase::AddAppBundlePaths() if(const char* path = this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH")) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } } + this->AddPaths(paths); } void cmFindBase::AddCMakeVairables() @@ -538,16 +552,17 @@ void cmFindBase::AddCMakeVairables() std::string var = "CMAKE_"; var += this->CMakePathName; var += "_PATH"; + std::vector paths; if(const char* path = this->Makefile->GetDefinition(var.c_str())) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } if(this->SearchAppBundleLast) { if(const char* path = this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH")) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } } if(this->SearchFrameworkLast) @@ -555,20 +570,23 @@ void cmFindBase::AddCMakeVairables() if(const char* path = this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } } + this->AddPaths(paths); } void cmFindBase::AddSystemEnvironmentVairables() { // Add LIB or INCLUDE + std::vector paths; if(this->EnvironmentPath.size()) { - cmSystemTools::GetPath(this->SearchPaths, this->EnvironmentPath.c_str()); + cmSystemTools::GetPath(paths, this->EnvironmentPath.c_str()); } // Add PATH - cmSystemTools::GetPath(this->SearchPaths); + cmSystemTools::GetPath(paths); + this->AddPaths(paths); } void cmFindBase::AddCMakeSystemVariables() @@ -576,16 +594,17 @@ void cmFindBase::AddCMakeSystemVariables() std::string var = "CMAKE_SYSTEM_"; var += this->CMakePathName; var += "_PATH"; + std::vector paths; if(const char* path = this->Makefile->GetDefinition(var.c_str())) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } if(this->SearchAppBundleLast) { if(const char* path = this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH")) { - cmSystemTools::ExpandListArgument(path, this->SearchPaths); + cmSystemTools::ExpandListArgument(path, paths); } } if(this->SearchFrameworkLast) @@ -593,23 +612,28 @@ void cmFindBase::AddCMakeSystemVariables() if(const char* 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& paths) { std::vector finalPath; std::vector::iterator i; - for(i = this->SearchPaths.begin(); - i != this->SearchPaths.end(); ++i) + // glob and expand registry stuff from paths and put + // into finalPath + for(i = paths.begin(); + i != paths.end(); ++i) { cmSystemTools::ExpandRegistryValues(*i); cmSystemTools::GlobDirs(i->c_str(), finalPath); } - this->SearchPaths.clear(); - // convert all paths to unix slashes + // clear the path + paths.clear(); + // convert all paths to unix slashes and add search path suffixes + // if there are any for(i = finalPath.begin(); i != finalPath.end(); ++i) { @@ -623,7 +647,7 @@ void cmFindBase::ExpandRegistryAndCleanPath() std::string p = *i + std::string("/") + *j; // add to all paths because the search path may be modified // 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 @@ -632,7 +656,7 @@ void cmFindBase::ExpandRegistryAndCleanPath() { // put all search paths in because it may later be replaced // by lib64 stuff fixes bug 4009 - this->SearchPaths.push_back(*i); + paths.push_back(*i); } } diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index e7084a441..e9fae389a 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -42,13 +42,15 @@ public: protected: void PrintFindStuff(); void ExpandPaths(std::vector userPaths); + // add to the SearchPaths + void AddPaths(std::vector& paths); void AddFrameWorkPaths(); void AddAppBundlePaths(); void AddEnvironmentVairables(); void AddCMakeVairables(); void AddSystemEnvironmentVairables(); void AddCMakeSystemVariables(); - void ExpandRegistryAndCleanPath(); + void ExpandRegistryAndCleanPath(std::vector& paths); // see if the VariableName is already set in the cache, // also copy the documentation from the cache to VariableDocumentation // if it has documentation in the cache