Historically, find_package() does not guarantee the order in which directories
matching a search path containing a glob expression are processed in - the
"first valid package" will be selected if there are multiple candidates. In such
cases, which package is chosen is completely random and can change, potentially
leading to build failures and reproducibility issues. This is rather unexpected
and confusing for developers.
Now that CMake has bumped its major version, it's a good time to change default
sort order and direction could be changed to natural sorting with a descending
order. That will result in the newest version of a library being picked in case
there are multiple ones available.
Tweak find_package test to turn off as much searching of the host
environment as possible. This should make the tests less likely to be
affected in case the host system happens to have a package with the same
name as one of the test packages.
We are working on adding CPS support to find_package, which will
obviously require tests (ideally, and especially in the long term, a
non-trivial number thereof). While it would be possibly to lump these
into the already rather lengthy FindPackageTest, it seems likely they
can be kept separate. Therefore, rename FindPackageTest to
FindPackageCMakeTest so that the name FindPackageCpsTest will be
available.