Commit 6e1d3edb authored by Alexander Neundorf's avatar Alexander Neundorf

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.

parent 0751106f
......@@ -607,6 +607,24 @@ bool cmFindPackageCommand
std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
disableFindPackageVar += this->Name;
if (this->Required)
cmOStringStream e;
e << "for module " << this->Name << " called with REQUIRED, but "
<< disableFindPackageVar
<< " is enabled. A REQUIRED package cannot be disabled.";
return false;
return true;
// See if there is a Find<package>.cmake module.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment