summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-06-05 22:20:16 (GMT)
committerBrad King <brad.king@kitware.com>2008-06-05 22:20:16 (GMT)
commit789c167b6f4d7cc630be4baa78d14a8688722ddd (patch)
treea22d09e3030b1a301cdd957751bd31c732f6fe94 /Source/cmFindPackageCommand.cxx
parent3ecfb5f7e8e57d4c273d25eeaaecffea2cf51d09 (diff)
downloadCMake-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/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx88
1 files changed, 58 insertions, 30 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 741a08f..5cc1724 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -821,8 +821,9 @@ void cmFindPackageCommand::FindConfig()
//----------------------------------------------------------------------------
bool cmFindPackageCommand::FindPrefixedConfig()
{
- for(std::vector<std::string>::const_iterator pi = this->Prefixes.begin();
- pi != this->Prefixes.end(); ++pi)
+ std::vector<std::string>& prefixes = this->SearchPaths;
+ for(std::vector<std::string>::const_iterator pi = prefixes.begin();
+ pi != prefixes.end(); ++pi)
{
if(this->SearchPrefix(*pi))
{
@@ -835,8 +836,9 @@ bool cmFindPackageCommand::FindPrefixedConfig()
//----------------------------------------------------------------------------
bool cmFindPackageCommand::FindFrameworkConfig()
{
- for(std::vector<std::string>::const_iterator i = this->Prefixes.begin();
- i != this->Prefixes.end(); ++i)
+ std::vector<std::string>& prefixes = this->SearchPaths;
+ for(std::vector<std::string>::const_iterator i = prefixes.begin();
+ i != prefixes.end(); ++i)
{
if(this->SearchFrameworkPrefix(*i))
{
@@ -849,8 +851,9 @@ bool cmFindPackageCommand::FindFrameworkConfig()
//----------------------------------------------------------------------------
bool cmFindPackageCommand::FindAppBundleConfig()
{
- for(std::vector<std::string>::const_iterator i = this->Prefixes.begin();
- i != this->Prefixes.end(); ++i)
+ std::vector<std::string>& prefixes = this->SearchPaths;
+ for(std::vector<std::string>::const_iterator i = prefixes.begin();
+ i != prefixes.end(); ++i)
{
if(this->SearchAppBundlePrefix(*i))
{
@@ -939,19 +942,20 @@ void cmFindPackageCommand::AppendSuccessInformation()
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddUserPath(std::string const& p)
+void cmFindPackageCommand::ComputePrefixes()
{
- std::string userPath = p;
- cmSystemTools::ExpandRegistryValues(userPath);
- this->UserPaths.push_back(userPath);
+ this->AddPrefixesCMakeEnvironment();
+ this->AddPrefixesCMakeVariable();
+ this->AddPrefixesSystemEnvironment();
+ this->AddPrefixesBuilds();
+ this->AddPrefixesCMakeSystemVariable();
+ this->AddPrefixesUser();
+ this->ComputeFinalPrefixes();
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::ComputePrefixes()
+void cmFindPackageCommand::AddPrefixesCMakeEnvironment()
{
- std::vector<std::string>& prefixes = this->Prefixes;
- std::set<cmStdString> emmitted;
-
if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
{
// Check the environment variable with the same name as the cache
@@ -960,21 +964,29 @@ void cmFindPackageCommand::ComputePrefixes()
if(cmSystemTools::GetEnv(this->Variable.c_str(), env) && env.length() > 0)
{
cmSystemTools::ConvertToUnixSlashes(env);
- this->AddPathInternal(prefixes, env, EnvPath, &emmitted);
+ this->AddPathInternal(env, EnvPath);
}
- this->AddEnvPath(prefixes, "CMAKE_PREFIX_PATH", &emmitted);
- this->AddEnvPath(prefixes, "CMAKE_FRAMEWORK_PATH", &emmitted);
- this->AddEnvPath(prefixes, "CMAKE_APPBUNDLE_PATH", &emmitted);
+ this->AddEnvPath("CMAKE_PREFIX_PATH");
+ this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
+ this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
}
+}
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::AddPrefixesCMakeVariable()
+{
if(!this->NoCMakePath && !this->NoDefaultPath)
{
- this->AddCMakePath(prefixes, "CMAKE_PREFIX_PATH", &emmitted);
- this->AddCMakePath(prefixes, "CMAKE_FRAMEWORK_PATH", &emmitted);
- this->AddCMakePath(prefixes, "CMAKE_APPBUNDLE_PATH", &emmitted);
+ this->AddCMakePath("CMAKE_PREFIX_PATH");
+ this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
+ this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
}
+}
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::AddPrefixesSystemEnvironment()
+{
if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
{
// Use the system search path to generate prefixes.
@@ -991,17 +1003,19 @@ void cmFindPackageCommand::ComputePrefixes()
if(d.size() >= 4 && strcmp(d.c_str()+d.size()-4, "/bin") == 0 ||
d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0)
{
- this->AddPathInternal(prefixes,
- cmSystemTools::GetFilenamePath(d),
- EnvPath, &emmitted);
+ this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath);
}
else
{
- this->AddPathInternal(prefixes, d, EnvPath, &emmitted);
+ this->AddPathInternal(d, EnvPath);
}
}
}
+}
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::AddPrefixesBuilds()
+{
if(!this->NoBuilds && !this->NoDefaultPath)
{
// It is likely that CMake will have recently built the project.
@@ -1017,23 +1031,37 @@ void cmFindPackageCommand::ComputePrefixes()
if(cmSystemTools::FileIsFullPath(f.c_str()) &&
cmSystemTools::FileIsDirectory(f.c_str()))
{
- this->AddPathInternal(prefixes, f, FullPath, &emmitted);
+ this->AddPathInternal(f, FullPath);
}
}
}
+}
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::AddPrefixesCMakeSystemVariable()
+{
if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
{
- this->AddCMakePath(prefixes, "CMAKE_SYSTEM_PREFIX_PATH", &emmitted);
- this->AddCMakePath(prefixes, "CMAKE_SYSTEM_FRAMEWORK_PATH", &emmitted);
- this->AddCMakePath(prefixes, "CMAKE_SYSTEM_APPBUNDLE_PATH", &emmitted);
+ this->AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
+ this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
+ this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
}
+}
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::AddPrefixesUser()
+{
if(!this->UserPaths.empty())
{
// Add paths specified by the caller.
- this->AddPathsInternal(prefixes, this->UserPaths, CMakePath, &emmitted);
+ this->AddPathsInternal(this->UserPaths, CMakePath);
}
+}
+
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::ComputeFinalPrefixes()
+{
+ std::vector<std::string>& prefixes = this->SearchPaths;
// Construct the final set of prefixes.
this->RerootPaths(prefixes);