[cmake-developers] Patch: Don't emit warning when config file not found
Brad King
brad.king at kitware.com
Wed Apr 26 10:27:41 EDT 2017
On 04/25/2017 03:55 PM, Christoph Grüninger wrote:
> please find attached a first attempt to implement OPTIONAL for
> find_package. It is supposed to suppress all warnings and indicate the
> negative result by a single line of output. Unfortunately, I still get a
> warning and I could figure out how to simply print a message without the
> warning. Could you give me some hints and comment on my patch?
The IssueMessage API is for formatted diagnostics with backtraces.
Use DisplayStatus for a simple status line:
```
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 2f899a38ff..af64884d2b 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -844,8 +844,8 @@ bool cmFindPackageCommand::HandlePackageMode()
aw << "Could not find " << this->Name
<< ". (No " << this->Name
<< ".cmake or " << this->Name
- << "-config.cmake)\n";
- this->Makefile->IssueMessage(cmake::MESSAGE, aw.str());
+ << "-config.cmake)";
+ this->Makefile->DisplayStatus(aw.str().c_str(), -1);
}
// Set a variable marking whether the package was found.
```
One of the reasons the default message is so long is to help both
project authors when writing find_package calls (perhaps trying to
use a Find<pkg>.cmake file) and end-users trying to find a package.
Older forms of the message caused a lot of confusion about the role
of find modules (Find<pkg>.cmake) versus package configuration files
(<pkg>Config.cmake). We need to make sure new messages don't cause
such confusion again, so we should never have wording that mentions
both files.
When a find module is in use then the Find<pkg>.cmake module is
responsible for result messages. `find_package_handle_standard_args`
already constructs a nice single-line status message such as:
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Therefore I think the proposed status message is only needed in
CONFIG mode when we can't find a <pkg>Config.cmake file. IIUC you'd
like to replace the long-winded warning with something like:
-- Could NOT find Foo (missing: Foo_DIR)
Correct?
Thanks,
-Brad
More information about the cmake-developers
mailing list