FetchContent redirection of find_package() calls doesn't fully ignore version constraints
When FetchContent_MakeAvailable()
sets up its find_package()
redirection in the CMAKE_FIND_PACKAGE_REDIRECTS_DIR
, all future find_package()
calls for that dependency MUST accept those files as fulfilling the request, regardless of any version constraints such calls might specify. The automatically generated <pkgname>-config-version.cmake
file sets PACKAGE_VERSION_COMPATIBLE
to true so that any find_package()
call that includes a version constraint won't automatically fail. However, it should also set PACKAGE_VERSION_EXACT
to true in case find_package()
calls include the EXACT
keyword, but this is currently missing. The automatically generated file should be updated to set this variable as well.
Since this is a bug in the logic for a new feature added in CMake 3.24, the fix suggested above should be back ported to the release branch.