find_package: Fix NO_MODULE under CMAKE_FIND_PACKAGE_PREFER_CONFIG
The module mode fallback added by !3446 (merged) should not be used unless the find_package
call allows module mode. Doing so can lead to infinite recursion if a find module tries to call config mode with find_package(... NO_MODULE)
. Fix the logic and add a test case.
Fixes: #19478 (closed)
Topic-rename: find_package-fix-NO_MODULE
Edited by Brad King