Commit 8ed86860 authored by Cristian Adam's avatar Cristian Adam 💬 Committed by Brad King
Browse files

find_package: Fix prefer-config mode to not fail on missing optional package

When `CMAKE_FIND_PACKAGE_PREFER_CONFIG` mode was set to `ON`, failure to
find a package was fatal even if it was not `REQUIRED`.  Fix this and
add a test case.

Fixes: #19557
parent f43a7d76
......@@ -507,7 +507,9 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
loadedPackage = true;
} else {
// The package was not loaded. Report errors.
HandlePackageMode(HandlePackageModeType::Module);
if (HandlePackageMode(HandlePackageModeType::Module)) {
loadedPackage = true;
}
}
}
} else {
......
......@@ -625,3 +625,9 @@ find_package(ACME NO_MODULE)
if(ACME_FOUND)
message(SEND_ERROR "Should not find ACME package")
endif()
############################################################################
##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with unknown package
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
find_package(DoesNotExist)
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