diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-06-13 21:58:30 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2019-06-13 21:58:30 (GMT) |
commit | 22e65d10c175081ed5f21f86c7064c014fc3f39c (patch) | |
tree | a673d33900c33c132c1528072064cc1ec4970f57 /Source/cmFindPackageCommand.cxx | |
parent | a4231943117f5ba3dd0fdc6c8b1824334162b69f (diff) | |
download | CMake-22e65d10c175081ed5f21f86c7064c014fc3f39c.zip CMake-22e65d10c175081ed5f21f86c7064c014fc3f39c.tar.gz CMake-22e65d10c175081ed5f21f86c7064c014fc3f39c.tar.bz2 |
find_package: Fixed CMAKE_FIND_PACKAGE_PREFER_CONFIG Module fallback
Fixes: #19361
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8eefaa7..828488f 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -502,8 +502,13 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_PREFER_CONFIG")) { if (this->UseConfigFiles && this->FindPackageUsingConfigMode()) { loadedPackage = true; - } else if (this->FindPackageUsingModuleMode()) { - loadedPackage = true; + } else { + if (this->FindPackageUsingModuleMode()) { + loadedPackage = true; + } else { + // The package was not loaded. Report errors. + HandlePackageMode(HandlePackageModeType::Module); + } } } else { if (this->UseFindModules && this->FindPackageUsingModuleMode()) { @@ -603,7 +608,7 @@ bool cmFindPackageCommand::FindPackageUsingConfigMode() this->IgnoredPaths.insert(ignored.begin(), ignored.end()); // Find and load the package. - return this->HandlePackageMode(); + return this->HandlePackageMode(HandlePackageModeType::Config); } void cmFindPackageCommand::SetModuleVariables(const std::string& components) @@ -722,7 +727,8 @@ bool cmFindPackageCommand::FindModule(bool& found) return true; } -bool cmFindPackageCommand::HandlePackageMode() +bool cmFindPackageCommand::HandlePackageMode( + HandlePackageModeType handlePackageModeType) { this->ConsideredConfigs.clear(); @@ -817,6 +823,12 @@ bool cmFindPackageCommand::HandlePackageMode() } } + if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_PREFER_CONFIG") && !found && + handlePackageModeType == HandlePackageModeType::Config) { + // Config mode failed. Allow Module case. + result = false; + } + // package not found if (result && !found) { // warn if package required or neither quiet nor in config mode |