diff options
author | Brad King <brad.king@kitware.com> | 2021-07-08 12:06:05 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-07-08 12:06:12 (GMT) |
commit | a42b753c419136e3593042c62129bcaa36b50146 (patch) | |
tree | d44bb0be6afa4d2afcc1e5e905d0cfab1864839c /Source | |
parent | dad3a178a41efc2baa25fcb260a12991cdc94fef (diff) | |
parent | a2e9fe38e43bd73513cde410f83e53e0c31ec6d6 (diff) | |
download | CMake-a42b753c419136e3593042c62129bcaa36b50146.zip CMake-a42b753c419136e3593042c62129bcaa36b50146.tar.gz CMake-a42b753c419136e3593042c62129bcaa36b50146.tar.bz2 |
Merge topic 'find_package-required-var'
a2e9fe38e4 find_package: Add variable to make package REQUIRED
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Michael Hirsch <michael@scivision.dev>
Merge-request: !6316
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index fba736e..a0de74c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -478,17 +478,35 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) this->VersionMaxPatch, this->VersionMaxTweak); } + const std::string makePackageRequiredVar = + cmStrCat("CMAKE_REQUIRE_FIND_PACKAGE_", this->Name); + const bool makePackageRequiredSet = + this->Makefile->IsOn(makePackageRequiredVar); + if (makePackageRequiredSet) { + if (this->Required) { + this->Makefile->IssueMessage( + MessageType::WARNING, + cmStrCat("for module ", this->Name, + " already called with REQUIRED, thus ", + makePackageRequiredVar, " has no effect.")); + } else { + this->Required = true; + } + } + std::string disableFindPackageVar = cmStrCat("CMAKE_DISABLE_FIND_PACKAGE_", this->Name); if (this->Makefile->IsOn(disableFindPackageVar)) { if (this->Required) { this->SetError( - cmStrCat("for module ", this->Name, " called with REQUIRED, but ", - disableFindPackageVar, + cmStrCat("for module ", this->Name, + (makePackageRequiredSet + ? " was made REQUIRED with " + makePackageRequiredVar + : " called with REQUIRED, "), + " but ", disableFindPackageVar, " is enabled. A REQUIRED package cannot be disabled.")); return false; } - return true; } |