浏览代码

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.
Christoph Grüninger 8 年之前
父节点
当前提交
d0b9d1cceb

+ 10 - 2
Source/cmFindPackageCommand.cxx

@@ -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.

+ 0 - 15
Tests/RunCMake/find_package/MissingConfig-stderr.txt

@@ -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\):

+ 1 - 0
Tests/RunCMake/find_package/MissingConfig-stdout.txt

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

+ 1 - 0
Tests/RunCMake/find_package/MissingConfigNormal-stdout.txt

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

+ 0 - 10
Tests/RunCMake/find_package/MissingConfigOneName-stderr.txt

@@ -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\)

+ 1 - 0
Tests/RunCMake/find_package/MissingConfigOneName-stdout.txt

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

+ 0 - 13
Tests/RunCMake/find_package/MissingConfigVersion-stderr.txt

@@ -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\)

+ 1 - 0
Tests/RunCMake/find_package/MissingConfigVersion-stdout.txt

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

+ 0 - 9
Tests/RunCMake/find_package/SetFoundFALSE-stderr.txt

@@ -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\)

+ 1 - 0
Tests/RunCMake/find_package/SetFoundFALSE-stdout.txt

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