swift-argument-parser icon indicating copy to clipboard operation
swift-argument-parser copied to clipboard

Suppress needlessly alarming messages

Open dabrahams opened this issue 1 year ago • 9 comments
trafficstars

These packages are not marked REQUIRED and when this project is used as a dependency of another CMake project they don't need to be findable when this CMakeLists.txt is read. They may in fact be found later in the configuration process, so the messages when they actually are needed, so the messages

-- Could NOT find dispatch (missing: dispatch_DIR)
-- Could NOT find Foundation (missing: Foundation_DIR)
-- Could NOT find XCTest (missing: XCTest_DIR)

are needlessly alarming.

Replace this paragraph with a description of your changes and rationale. Provide links to an existing issue or external references/discussions, if appropriate.

Checklist

  • [x] I've added at least one test that validates that my change is working, if appropriate
  • [x] I've followed the code style of the rest of the project
  • [x] I've read the Contribution Guidelines
  • [x] I've updated the documentation if necessary

dabrahams avatar Apr 03 '24 20:04 dabrahams

@swift-ci please test

compnerd avatar Apr 07 '24 18:04 compnerd

Yeah, I'd prefer to keep the logging. If they aren't a WARNING, and aren't an ERROR, they won't prevent you from continuing and are just informational, but if they aren't emitted and you were expecting to find them, having that in the log is definitely preferable to scratching your head wondering why things were getting built weirdly.

etcwilde avatar Apr 08 '24 01:04 etcwilde

Maybe instead of marking these QUIET, we could add an additional message that contextualizes the output?

natecook1000 avatar Apr 09 '24 21:04 natecook1000

Maybe you could conditionally find_package based on the conditions that actually require them, and under those conditions make them REQUIRED? The current situation:

  • For developers of this package, defers errors to link time with a much harder-to-understand message, after you've wasted a bunch of time proceeding past an unrecoverable condition
  • For consumers of this package, produces confusing messages—in my case, for example XCTest actually is found, only later. So it's not just alarming, it's misleading to see this message.

dabrahams avatar Apr 16 '24 17:04 dabrahams

@dabrahams the condition that you need find_package is not a very helpful heuristic. We cannot infer if the user is intending to build against a custom build of any of those libraries or against the toolchain distribution of the libraries. The common case for building this library with CMake is intended to be against a custom build and you should do a find_package.

I can see an argument for eliding the find_package on macOS as we cannot build the dependencies on macOS in the OSS release, but outside of that, I think that the current behaviour is the preferred option.

compnerd avatar Sep 17 '24 18:09 compnerd

@compnerd I don't understand what your comment means. I wasn't suggesting any heuristic. I don't think there's any reason it should make a difference which version of those libraries are needed for any particular build. Assuming you want to keep the find_package calls, all I'm suggesting is that they be marked QUIET.

dabrahams avatar Sep 23 '24 18:09 dabrahams

The normal usage for the build is with a custom build of the dependencies and therefore the default should be non-QUIET. The special case is Darwin, where these are system provided, so we could exclude the checks there.

compnerd avatar Sep 23 '24 18:09 compnerd

I still don't understand the "therefore." Does using a custom build of the dependencies require that they have been set up by that point?

Are they really dependencies at all? dispatch only appears in that file. I… guess Foundation is a real dependency. And XCTest is only a dependency if you're building testing, so it find_package for that should only happen if BUILD_TESTING is set.

dabrahams avatar Sep 23 '24 19:09 dabrahams

I still don't understand the "therefore." Does using a custom build of the dependencies require that they have been set up by that point?

Yes, the custom build of dependencies requires that they are setup by that point (except on Darwin where they are system provided).

Are they really dependencies at all? dispatch only appears in that file. I… guess Foundation is a real dependency.

Yes, dispatch is a transitive dependency due to Foundation.

And XCTest is only a dependency if you're building testing, so it find_package for that should only happen if BUILD_TESTING is set.

That is a great suggestion! We should conditionalise the find_package(XCTest) under BUILD_TESTING.

compnerd avatar Sep 24 '24 04:09 compnerd