CMake 3.19’s `find_package` does not search in /lib/cmake/<name>
Hi.
First off, I discovered this bug when I build clang 11.0 with CMake
3.19. Here is the relevant part from
[llvmorg-11.0.0/clang/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/llvmorg-11.0.0/clang/CMakeLists.txt):
```cmake
find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
```
In fact, CMake 3.18 was using `/lib/clang/llvm/LLVMConfig.cmake`, which
is what I wanted, but realized that CMake 3.19 was using
`/usr/lib/clang/llvm/LLVMConfig.cmake` instead (NOTE: `LLVM_CMAKE_PATH`
is empty).
---
The behavior of `find_package` seems to have changed between CMake 3.18
and 3.19. In fact, when `find_package(FOO)` will search for
`/usr/lib/cmake/foo/{FOOConfig,foo-config}.cmake` but not for
`/lib/cmake/foo/{FOOConfig,foo-config}.cmake` in the new 3.19-rc1. Is
this expected?
Here is a minimal reproducible example. I used Sourcehut Builds with
Alpine 3.12 to build CMake 3.18 and CMake 3.19, both with `/usr` and `/`
as prefix (as I found out, the prefix does not alter the behavior). I
also executed the compiled CMake on a dummy project.
```cmake
cmake_minimum_required(VERSION 3.18)
project(hello)
find_package(FOO)
add_executable(hello main.c)
```
```c
#include <stdio.h>
int main(void) { puts("hello"); }
```
Here is the output with `-D CMAKE_FIND_DEBUG_MODE=ON`:
CMake 3.18.4 with / as prefix:
https://builds.sr.ht/~iemaghni/job/321608#task-build-2329
CMake 3.19.0-rc1 with / as prefix:
https://builds.sr.ht/~iemaghni/job/321587#task-build-2329
CMake 3.18.4 with /usr as prefix:
https://builds.sr.ht/~iemaghni/job/321639#task-build-2248
CMake 3.19.0-rc1 with /usr as prefix:
https://builds.sr.ht/~iemaghni/job/321621#task-build-2249
Here is the essential output for CMake 3.18.4:
```
find_package considered the following locations for the Config module:
/FOOConfig.cmake
/foo-config.cmake
/lib/cmake/foo/FOOConfig.cmake
/lib/cmake/foo/foo-config.cmake
/usr/FOOConfig.cmake
/usr/foo-config.cmake
/usr/lib/cmake/foo/FOOConfig.cmake
/usr/lib/cmake/foo/foo-config.cmake
/usr/local/FOOConfig.cmake
/usr/local/foo-config.cmake
/opt/FOOConfig.cmake
/opt/foo-config.cmake
The file was not found.
```
and for CMake 3.19.0-rc1:
```
find_package considered the following locations for the Config module:
/FOOConfig.cmake
/foo-config.cmake
/usr/FOOConfig.cmake
/usr/foo-config.cmake
/usr/lib/cmake/foo/FOOConfig.cmake
/usr/lib/cmake/foo/foo-config.cmake
/usr/local/FOOConfig.cmake
/usr/local/foo-config.cmake
/opt/FOOConfig.cmake
/opt/foo-config.cmake
The file was not found.
```
As you see, these two lines are missing from the new version:
```
/lib/cmake/foo/FOOConfig.cmake
/lib/cmake/foo/foo-config.cmake
```
Here is the template that I used. Only `CMAKE_VER`, `CMAKE_CHKSUM` and
`--prefix=` change between the builds:
```yaml
image: alpine/3.12
packages:
- pigz
- linux-headers
environment:
CMAKE_VER: 3.18.4
CMAKE_CHKSUM: 597c61358e6a92ecbfad42a9b5321ddd801fc7e7eca08441307c9138382d4f77
tasks:
- build: |
>"cmake-${CMAKE_VER}.tar.gz" curl "https://cmake.org/files/v${CMAKE_VER%.*}/cmake-${CMAKE_VER}.tar.gz"
set -- $(sha256sum "cmake-${CMAKE_VER}.tar.gz")
test "$1" = "$CMAKE_CHKSUM"
<"cmake-${CMAKE_VER}.tar.gz" pigz -d | tar -x -f -
MAKEFLAGS="-j $(nproc)"
export MAKEFLAGS
mkdir -p cmake-build test test-build
cd cmake-build
"../cmake-${CMAKE_VER}/bootstrap" --prefix=/ -- -D CMAKE_USE_OPENSSL=OFF
>'/dev/null' make
sudo make install
cd ../test
>'CMakeLists.txt' printf 'cmake_minimum_required(VERSION 3.18)\nproject(hello)\nfind_package(FOO)\nadd_executable(hello main.c)\n'
>'main.c' printf '#include <stdio.h>\nint main(void) { puts("hello"); }\n'
cd ../test-build
sudo mkdir -p /usr/lib/cmake/foo /lib/cmake/foo
cmake -D CMAKE_FIND_DEBUG_MODE=ON ../test
make
./hello
```
issue