summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-06-16 19:11:06 (GMT)
committerAlex Neundorf <neundorf@kde.org>2011-06-21 19:18:23 (GMT)
commit6e1d3edb4d1e1b491df879a2764d8a24442795dc (patch)
tree4bf936866974aeff11d09c8e94a4347a39267f45 /Source/cmFindPackageCommand.cxx
parent0751106f2fbfd1a5eb8c4572f60209cc9b22f841 (diff)
downloadCMake-6e1d3edb4d1e1b491df879a2764d8a24442795dc.zip
CMake-6e1d3edb4d1e1b491df879a2764d8a24442795dc.tar.gz
CMake-6e1d3edb4d1e1b491df879a2764d8a24442795dc.tar.bz2
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
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 5f106bc..554601d 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -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.