find_package: shorten output for missing package in config mode

If CONFIG or MODULE is given and the package is not REQUIRED,
output a one-liner instead of the full warning.

Update Tests/RunCMake/find_package expected output to match.
This commit is contained in:
Christoph Grüninger 2017-05-09 07:13:45 +02:00 committed by Brad King
parent d9df805f6a
commit d0b9d1cceb
10 changed files with 15 additions and 49 deletions

View File

@ -729,8 +729,9 @@ bool cmFindPackageCommand::HandlePackageMode()
// package not found
if (result && !found) {
// warn if package required and not quiet
if (!this->Quiet || this->Required) {
// warn if package required or neither quiet nor in config mode
if (this->Required ||
!(this->Quiet || (this->UseConfigFiles && !this->UseFindModules))) {
// The variable is not set.
std::ostringstream e;
std::ostringstream aw;
@ -832,6 +833,13 @@ bool cmFindPackageCommand::HandlePackageMode()
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
}
}
// output result if in config mode but not in quiet mode
else if (!this->Quiet) {
std::ostringstream aw;
aw << "Could NOT find " << this->Name << " (missing: " << this->Name
<< "_DIR)";
this->Makefile->DisplayStatus(aw.str().c_str(), -1);
}
}
// Set a variable marking whether the package was found.

View File

@ -1,18 +1,3 @@
CMake Warning at MissingConfig.cmake:1 \(find_package\):
Could not find a package configuration file provided by "NotHere" with any
of the following names:
NotHereConfig.cmake
nothere-config.cmake
Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set
"NotHere_DIR" to a directory containing one of the above files. If
"NotHere" provides a separate development package or SDK, be sure it has
been installed.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
CMake Warning at MissingConfig.cmake:2 \(message\):
This warning must be reachable.
Call Stack \(most recent call first\):

View File

@ -0,0 +1 @@
-- Could NOT find NotHere \(missing: NotHere_DIR\)

View File

@ -0,0 +1 @@
-- Could NOT find NotHere \(missing: NotHere_DIR\)

View File

@ -1,10 +0,0 @@
CMake Warning at MissingConfigOneName.cmake:1 \(find_package\):
Could not find a package configuration file named "NotHereConfig.cmake"
provided by package "NotHere".
Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set
"NotHere_DIR" to a directory containing one of the above files. If
"NotHere" provides a separate development package or SDK, be sure it has
been installed.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
-- Could NOT find NotHere \(missing: NotHere_DIR\)

View File

@ -1,13 +0,0 @@
CMake Warning at MissingConfigVersion.cmake:1 \(find_package\):
Could not find a package configuration file provided by "NotHere"
\(requested version 1\.2\) with any of the following names:
NotHereConfig.cmake
nothere-config.cmake
Add the installation prefix of "NotHere" to CMAKE_PREFIX_PATH or set
"NotHere_DIR" to a directory containing one of the above files. If
"NotHere" provides a separate development package or SDK, be sure it has
been installed.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
-- Could NOT find NotHere \(missing: NotHere_DIR\)

View File

@ -1,9 +0,0 @@
CMake Warning at SetFoundFALSE.cmake:2 \(find_package\):
Found package configuration file:
.*/Tests/RunCMake/find_package/SetFoundFALSEConfig.cmake
but it set SetFoundFALSE_FOUND to FALSE so package "SetFoundFALSE" is
considered to be NOT FOUND.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
-- Could NOT find SetFoundFALSE \(missing: SetFoundFALSE_DIR\)