find_package: Fix reporting of transitive dependency errors

Fix find_package to set an error message when trying to find
dependencies of a CPS package fails. This fixes the command previously
reporting "find_package unknown error" for such failures.
This commit is contained in:
Matthew Woehlke
2025-01-30 14:03:56 -05:00
committed by Brad King
parent 0bd26d4527
commit ac20cd43c0
2 changed files with 7 additions and 0 deletions

View File

@@ -1969,6 +1969,8 @@ bool cmFindPackageCommand::FindPackageDependencies(
// Try to find the requirement; fail if we can't.
if (!fp.FindPackage() || fp.FileFound.empty()) {
this->SetError(cmStrCat("could not find "_s, dep.Name,
", required by "_s, this->Name, '.'));
return false;
}
}

View File

@@ -23,3 +23,8 @@ Call Stack \(most recent call first\):
cps/[Ii]ncomplete\.cps
MissingTransitiveDependency\.cmake:[0-9]+ \(find_package\)
CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at MissingTransitiveDependency\.cmake:[0-9]+ \(find_package\):
find_package could not find StillIncomplete, required by Incomplete\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)