find_package unsets custom install location provided by cmake command line
In the kmymoney project, it was recently discovered that a user-specific package path is no longer available after the find_package call if the package was not found. In this particular case, libalkimia version 7.0.2 was installed and the following cmake code fragment was used to find libalkimia.
find_package(LibAlkimia5 8.0) if (NOT LibAlkimia5_FOUND) find_package(LibAlkimia5 7.0 REQUIRED) endif()
The config based find_package module installed by libalkimia uses 'SameMajorVersion' compatibility.
cmake -DLibAlkimia5_DIR=xxxx <kmymoney-source-dir>
the second find_package call could not find the package with version 7.0.0. It was detected that LibAlkimia5_DIR was set to LibAlkimia5_DIR-NOTFOUND in the CMakeCache.txt by the first find_package call and was no longer available for the second call.
As a workaround, the relevant _DIR variable has been restored (see https://cgit.kde.org/kmymoney.git/commit/?h=5.0&id=5cf4c62fd0109b6ab8b42d3429e96b361a2e5ee0)