Add a switch to disable a find_package() call completely
As discussed, this adds a switch CMAKE_DISABLE_FIND_PACKAGE_<name>, which, when set to TRUE, keeps the find_package() command from executing. When the package is REQUIRED at the same time, an error is generated. Alex
This commit is contained in:
parent
0751106f2f
commit
6e1d3edb4d
|
@ -607,6 +607,24 @@ bool cmFindPackageCommand
|
|||
}
|
||||
}
|
||||
|
||||
std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
|
||||
disableFindPackageVar += this->Name;
|
||||
if(this->Makefile->IsOn(disableFindPackageVar.c_str()))
|
||||
{
|
||||
if (this->Required)
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "for module " << this->Name << " called with REQUIRED, but "
|
||||
<< disableFindPackageVar
|
||||
<< " is enabled. A REQUIRED package cannot be disabled.";
|
||||
this->SetError(e.str().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
this->SetModuleVariables(components);
|
||||
|
||||
// See if there is a Find<package>.cmake module.
|
||||
|
|
Loading…
Reference in New Issue