Find_Package fails for package with only module when CMAKE_FIND_PACKAGE_PREFER_CONFIG is ON
The documentation indicates that CMAKE_FIND_PACKAGE_PREFER_CONFIG should tell find_package to try config, and then try module packages. However when trying this option out I found that it makes find_package ONLY use config mode packages.
The following CMakeLists.txt file demonstrates the issue
cmake_minimum_required(VERSION 3.15) project(scratch) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) find_package(OpenSSL REQUIRED)
Running this on a machine with OpenSSL installed will fail, unless CMAKE_FIND_PACKAGE_PREFER_CONFIG is set to OFF