summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-01-22 15:40:48 (GMT)
committerBrad King <brad.king@kitware.com>2003-01-22 15:40:48 (GMT)
commitaf96ba019ef7eb5d393534b2870597771fcbe409 (patch)
tree365f6b491af7ea5874eae3f7a7a59c2d4251fda2
parent486454ef781a441334e876eef0c5d058526e97d4 (diff)
downloadCMake-af96ba019ef7eb5d393534b2870597771fcbe409.zip
CMake-af96ba019ef7eb5d393534b2870597771fcbe409.tar.gz
CMake-af96ba019ef7eb5d393534b2870597771fcbe409.tar.bz2
ENH: Added support for looking through CMAKE_MODULE_PATH to locate Find<name>.cmake modules.
-rw-r--r--Source/cmFindPackageCommand.cxx41
1 files changed, 31 insertions, 10 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index c61cde2..4f0681f 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -101,18 +101,39 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
//----------------------------------------------------------------------------
bool cmFindPackageCommand::FindModule(bool& found)
{
- // If there is a find module, use it.
- std::string module = m_Makefile->GetDefinition("CMAKE_ROOT");
- module += "/Modules/Find";
- module += this->Name;
- module += ".cmake";
+ // Search the CMAKE_MODULE_PATH for a Find<name>.cmake module.
found = false;
- // TODO: CMAKE_PACKAGE_PATH for looking for Find<name>.cmake
- // modules?
- if(cmSystemTools::FileExists(module.c_str()))
+ std::string module;
+ std::vector<std::string> modulePath;
+ const char* def = m_Makefile->GetDefinition("CMAKE_MODULE_PATH");
+ if(def)
{
- found = true;
- return this->ReadListFile(module.c_str());
+ cmSystemTools::ExpandListArgument(def, modulePath);
+ }
+
+ // Also search in the standard modules location.
+ def = m_Makefile->GetDefinition("CMAKE_ROOT");
+ if(def)
+ {
+ std::string rootModules = def;
+ rootModules += "/Modules";
+ modulePath.push_back(rootModules);
+ }
+
+ // Look through the possible module directories.
+ for(std::vector<std::string>::iterator i = modulePath.begin();
+ i != modulePath.end(); ++i)
+ {
+ module = *i;
+ cmSystemTools::ConvertToUnixSlashes(module);
+ module += "/Find";
+ module += this->Name;
+ module += ".cmake";
+ if(cmSystemTools::FileExists(module.c_str()))
+ {
+ found = true;
+ return this->ReadListFile(module.c_str());
+ }
}
return true;
}