[Cmake-commits] [cmake-commits] king committed cmFindPackageCommand.cxx 1.46 1.47
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Oct 3 10:40:09 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv15227/Source
Modified Files:
cmFindPackageCommand.cxx
Log Message:
ENH: Help recursive find_package calls in modules
These changes teach find_package to behave nicely when invoked
recursively inside a find-module for the same package. The module will
never be recursively loaded again. Version arguments are automatically
forwarded.
Index: cmFindPackageCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v
retrieving revision 1.46
retrieving revision 1.47
diff -C 2 -d -r1.46 -r1.47
*** cmFindPackageCommand.cxx 3 Oct 2008 14:39:53 -0000 1.46
--- cmFindPackageCommand.cxx 3 Oct 2008 14:40:05 -0000 1.47
***************
*** 130,134 ****
"The NO_MODULE option may be used to skip Module mode explicitly. "
"It is also implied by use of options not specified in the reduced "
! "signature. "
"\n"
"Config mode attempts to locate a configuration file provided by the "
--- 130,135 ----
"The NO_MODULE option may be used to skip Module mode explicitly. "
"It is also implied by use of options not specified in the reduced "
! "signature, or when the command is invoked recursively inside a "
! "find-module for the package."
"\n"
"Config mode attempts to locate a configuration file provided by the "
***************
*** 161,164 ****
--- 162,169 ----
"If the EXACT option is given only a version of the package claiming "
"an exact match of the requested version may be found. "
+ "If no [version] is given to a recursive invocation inside a "
+ "find-module, the [version] and EXACT arguments are forwarded "
+ "automatically from the outer call."
+ "\n"
"CMake does not establish any convention for the meaning of version "
"numbers. "
***************
*** 477,480 ****
--- 482,512 ----
}
+ if(!this->NoModule || this->Version.empty())
+ {
+ // Check whether we are recursing inside "Find<name>.cmake" within
+ // another find_package(<name>) call.
+ std::string mod = this->Name;
+ mod += "_FIND_MODULE";
+ if(this->Makefile->IsOn(mod.c_str()))
+ {
+ // Avoid recursing back into the module.
+ this->NoModule = true;
+
+ // Get version information from the outer call if necessary.
+ if(this->Version.empty())
+ {
+ // Requested version string.
+ std::string ver = this->Name;
+ ver += "_FIND_VERSION";
+ this->Version = this->Makefile->GetSafeDefinition(ver.c_str());
+
+ // Whether an exact version is required.
+ std::string exact = this->Name;
+ exact += "_FIND_VERSION_EXACT";
+ this->VersionExact = this->Makefile->IsOn(exact.c_str());
+ }
+ }
+ }
+
if(!this->Version.empty())
{
***************
*** 612,618 ****
if ( mfile.size() )
{
! // Load the module we found.
found = true;
! return this->ReadListFile(mfile.c_str());
}
return true;
--- 644,656 ----
if ( mfile.size() )
{
! // Load the module we found, and set "<name>_FIND_MODULE" to true
! // while inside it.
found = true;
! std::string var = this->Name;
! var += "_FIND_MODULE";
! this->Makefile->AddDefinition(var.c_str(), "1");
! bool result = this->ReadListFile(mfile.c_str());
! this->Makefile->RemoveDefinition(var.c_str());
! return result;
}
return true;
More information about the Cmake-commits
mailing list