diff options
author | Brad King <brad.king@kitware.com> | 2008-06-05 22:20:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-06-05 22:20:16 (GMT) |
commit | 789c167b6f4d7cc630be4baa78d14a8688722ddd (patch) | |
tree | a22d09e3030b1a301cdd957751bd31c732f6fe94 /Source/cmFindCommon.cxx | |
parent | 3ecfb5f7e8e57d4c273d25eeaaecffea2cf51d09 (diff) | |
download | CMake-789c167b6f4d7cc630be4baa78d14a8688722ddd.zip CMake-789c167b6f4d7cc630be4baa78d14a8688722ddd.tar.gz CMake-789c167b6f4d7cc630be4baa78d14a8688722ddd.tar.bz2 |
ENH: Refactor cmFindCommon, cmFindBase, and cmFindPackageCommand
- Add each part of the search order in a separate method.
- Collect added paths in an ivar in cmFindCommon.
- Move user path storage up to cmFindCommon and share
between cmFindBase and cmFindPackageCommand.
- Expand user path registry values up in cmFindCommon
- Enables 32-/64-bit registry view for find_package
- Disables registry expansion for paths not specified
with the PATHS argument, which is not expected.
Diffstat (limited to 'Source/cmFindCommon.cxx')
-rw-r--r-- | Source/cmFindCommon.cxx | 126 |
1 files changed, 33 insertions, 93 deletions
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 0c6af0d..a82e611 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -322,93 +322,39 @@ void cmFindCommon::AddPathSuffix(std::string const& arg) } //---------------------------------------------------------------------------- -void cmFindCommon::GetAppBundlePaths(std::vector<std::string>& paths) +void cmFindCommon::AddUserPath(std::string const& p) { - if(this->NoDefaultPath) - { - return; - } - std::vector<std::string> tmp; - - // first environment variables - if(!this->NoCMakeEnvironmentPath) - { - cmSystemTools::GetPath(tmp, "CMAKE_APPBUNDLE_PATH"); - this->AddPathsInternal(paths, tmp, EnvPath); - tmp.clear(); - } - - // add cmake variables - if(!this->NoCMakePath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH")) + // We should view the registry as the target application would view + // it. + cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32; + cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64; + if(const char* psize = + this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P")) + { + if(atoi(psize) == 8) { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); + view = cmSystemTools::KeyWOW64_64; + other_view = cmSystemTools::KeyWOW64_32; } } - // add cmake system variables - if(!this->NoCMakeSystemPath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH")) - { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); - } - } -} + // Expand using the view of the target application. + std::string expanded = p; + cmSystemTools::ExpandRegistryValues(expanded, view); + cmSystemTools::GlobDirs(expanded.c_str(), this->UserPaths); -//---------------------------------------------------------------------------- -void cmFindCommon::GetFrameworkPaths(std::vector<std::string>& paths) -{ - if(this->NoDefaultPath) + // Executables can be either 32-bit or 64-bit, so expand using the + // alternative view. + if(expanded != p && this->CMakePathName == "PROGRAM") { - return; - } - std::vector<std::string> tmp; - - // first environment variables - if(!this->NoCMakeEnvironmentPath) - { - cmSystemTools::GetPath(tmp, "CMAKE_FRAMEWORK_PATH"); - this->AddPathsInternal(paths, tmp, EnvPath); - tmp.clear(); - } - - // add cmake variables - if(!this->NoCMakePath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) - { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); - } - } - - // add cmake system variables - if(!this->NoCMakeSystemPath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH")) - { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); - } + expanded = p; + cmSystemTools::ExpandRegistryValues(expanded, other_view); + cmSystemTools::GlobDirs(expanded.c_str(), this->UserPaths); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddCMakePath(std::vector<std::string>& out_paths, - const char* variable, - std::set<cmStdString>* emmitted) +void cmFindCommon::AddCMakePath(const char* variable) { // Get a path from a CMake variable. if(const char* varPath = this->Makefile->GetDefinition(variable)) @@ -418,14 +364,12 @@ void cmFindCommon::AddCMakePath(std::vector<std::string>& out_paths, // Relative paths are interpreted with respect to the current // source directory. - this->AddPathsInternal(out_paths, tmp, CMakePath, emmitted); + this->AddPathsInternal(tmp, CMakePath); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddEnvPath(std::vector<std::string>& out_paths, - const char* variable, - std::set<cmStdString>* emmitted) +void cmFindCommon::AddEnvPath(const char* variable) { // Get a path from the environment. std::vector<std::string> tmp; @@ -433,27 +377,23 @@ void cmFindCommon::AddEnvPath(std::vector<std::string>& out_paths, // Relative paths are interpreted with respect to the current // working directory. - this->AddPathsInternal(out_paths, tmp, EnvPath, emmitted); + this->AddPathsInternal(tmp, EnvPath); } //---------------------------------------------------------------------------- -void cmFindCommon::AddPathsInternal(std::vector<std::string>& out_paths, - std::vector<std::string> const& in_paths, - PathType pathType, - std::set<cmStdString>* emmitted) +void cmFindCommon::AddPathsInternal(std::vector<std::string> const& in_paths, + PathType pathType) { for(std::vector<std::string>::const_iterator i = in_paths.begin(); i != in_paths.end(); ++i) { - this->AddPathInternal(out_paths, *i, pathType, emmitted); + this->AddPathInternal(*i, pathType); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddPathInternal(std::vector<std::string>& out_paths, - std::string const& in_path, - PathType pathType, - std::set<cmStdString>* emmitted) +void cmFindCommon::AddPathInternal(std::string const& in_path, + PathType pathType) { if(in_path.empty()) { @@ -471,9 +411,9 @@ void cmFindCommon::AddPathInternal(std::vector<std::string>& out_paths, std::string fullPath = cmSystemTools::CollapseFullPath(in_path.c_str(), relbase); - // Insert the path if has not already been emmitted. - if(!emmitted || emmitted->insert(fullPath).second) + // Insert the path if has not already been emitted. + if(this->SearchPathsEmitted.insert(fullPath).second) { - out_paths.push_back(fullPath.c_str()); + this->SearchPaths.push_back(fullPath.c_str()); } } |