[Cmake-commits] [cmake-commits] alex committed cmFindPackageCommand.h 1.26 1.27 cmFindPackageCommand.cxx 1.54 1.55
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jan 8 17:57:54 EST 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv823
Modified Files:
cmFindPackageCommand.h cmFindPackageCommand.cxx
Log Message:
ENH: when trying to find a FooConfig.cmake file, if in the directory pointed
to by the Foo_DIR variable there is no FooConfig.cmake file, then instead of
abort and complain that the user should set or clear the Foo_DIR variables,
just search for the file and discard the old Foo_DIR contents
The tests succeed, ok by Brad.
Alex
Index: cmFindPackageCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -C 2 -d -r1.26 -r1.27
*** cmFindPackageCommand.h 9 Dec 2008 15:08:54 -0000 1.26
--- cmFindPackageCommand.h 8 Jan 2009 22:57:52 -0000 1.27
***************
*** 98,102 ****
bool CheckDirectory(std::string const& dir);
bool FindConfigFile(std::string const& dir, std::string& file);
- bool FindConfigFileToLoad(std::string const& dir, std::string& file);
bool CheckVersion(std::string const& config_file);
bool CheckVersionFile(std::string const& version_file);
--- 98,101 ----
Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.54
retrieving revision 1.55
diff -C 2 -d -r1.54 -r1.55
*** cmFindPackageCommand.cxx 17 Dec 2008 14:24:05 -0000 1.54
--- cmFindPackageCommand.cxx 8 Jan 2009 22:57:52 -0000 1.55
***************
*** 711,725 ****
}
! // Search for the config file if it is not already found.
! if(cmSystemTools::IsOff(def))
! {
! this->FindConfig();
! def = this->Makefile->GetDefinition(this->Variable.c_str());
! }
!
! // If the config file was found, load it.
! std::string file;
! bool result = true;
! bool found = false;
if(!cmSystemTools::IsOff(def))
{
--- 711,716 ----
}
! // Try to load the config file if the directory is known
! bool cachedDirectoryOk = false;
if(!cmSystemTools::IsOff(def))
{
***************
*** 734,769 ****
dir = this->Makefile->GetCurrentDirectory() + dir;
}
!
! // Find the configuration file.
! if(this->FindConfigFileToLoad(dir, file))
{
! // Set the version variables before loading the config file.
! // It may override them.
! this->StoreVersionFound();
! // Parse the configuration file.
! if(this->ReadListFile(file.c_str()))
! {
! // The package has been found.
! found = true;
! }
! else
! {
! // The configuration file is invalid.
! result = false;
! }
}
else
{
! // The variable setting is wrong.
! cmOStringStream e;
! e << "cannot find package " << this->Name << " because "
! << this->Variable << " is set to \"" << def << "\" "
! << "which is not a directory containing a package configuration "
! << "file (or it is not for the requested version). "
! << "Please set the cache entry " << this->Variable << " "
! << "to the correct directory, or delete it to ask CMake "
! << "to search.";
! this->SetError(e.str().c_str());
result = false;
}
--- 725,766 ----
dir = this->Makefile->GetCurrentDirectory() + dir;
}
! // The file location was cached. Look for the correct file.
! std::string file;
! if (this->FindConfigFile(dir, file))
{
! this->FileFound = file;
! cachedDirectoryOk = true;
! }
! def = this->Makefile->GetDefinition(this->Variable.c_str());
! }
! // Search for the config file if it is not already found.
! if(cmSystemTools::IsOff(def) || !cachedDirectoryOk)
! {
! this->FindConfig();
! def = this->Makefile->GetDefinition(this->Variable.c_str());
! }
!
! // If the directory for the config file was found, try to read the file.
! bool result = true;
! bool found = false;
! // in the following test FileFound should never be empty if def is valid
! // but I don't want to put an assert() in there now, in case this still
! // makes it into 2.6.3
! if(!cmSystemTools::IsOff(def) && (!this->FileFound.empty()))
! {
! // Set the version variables before loading the config file.
! // It may override them.
! this->StoreVersionFound();
!
! // Parse the configuration file.
! if(this->ReadListFile(this->FileFound.c_str()))
! {
! // The package has been found.
! found = true;
}
else
{
! // The configuration file is invalid.
result = false;
}
***************
*** 817,821 ****
if(found)
{
! this->Makefile->AddDefinition(fileVar.c_str(), file.c_str());
}
else
--- 814,818 ----
if(found)
{
! this->Makefile->AddDefinition(fileVar.c_str(), this->FileFound.c_str());
}
else
***************
*** 1246,1267 ****
//----------------------------------------------------------------------------
- bool cmFindPackageCommand::FindConfigFileToLoad(std::string const& dir,
- std::string& file)
- {
- if(this->FileFound.empty())
- {
- // The file location was cached. Look for the correct file.
- return this->FindConfigFile(dir, file);
- }
- else
- {
- // The file location was just found during this call.
- // Use the file found without searching again.
- file = this->FileFound;
- return true;
- }
- }
-
- //----------------------------------------------------------------------------
bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
{
--- 1243,1246 ----
More information about the Cmake-commits
mailing list