Generated cmake configuration file is invalid with CMake 3.29.1
Summary
In the dune <module>-config.cmake
files, we use the cmake variable PACKAGE_PREFIX_DIR
for the initialization of the <module>_PREFIX
variable. This PACKAGE_PREFIX_DIR
seems to be only an internal variable and not mentioned in the cmake-documentation. With cmake 3.29 in MR https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9390 the variable is renamed into something that we cannot directly use, PACKAGE_<MODULE>_COUNTER_<COUNTER>
where the counter might be anything but is typically just 1
.
So, we have to find a new way to determine the location for the <module>_PREFIX
path. This must also be compatible between build and install environment.
Steps to reproduce
With cmake 3.29.1 configure dune-common, build, and install. The installed <install-prefix>/lib/cmake/dune-common/dune-common-config.cmake
contains the empty variable set_and_check(dune-common_PREFIX "${PACKAGE_PREFIX_DIR}")
. This is, because line 13 was changed
# from (cmake < 3.29.1)
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
# to (cmake = 3.29.1)
get_filename_component(PACKAGE_${CMAKE_FIND_PACKAGE_NAME}_COUNTER_1 "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
and thus the variable PACKAGE_PREFIX_DIR
is now unset.
Reference
This issue was first reported in the Dune support chat by user Oromion.