Is there a proper way for a CMake package to propagate variables (in particular, CMAKE_MODULE_PATH) to any consuming projects? I’ve got a package that provides some find modules, and in its CMakeLists.txt, it adds the appropriate path to CMAKE_MODULE_PATH and everything works as expected. However, if I add this package to a consuming project using FetchContent, and then try to use one of its find modules from the superproject, I get errors that the requested find module isn’t in CMAKE_MODULE_PATH.
Is the only answer to have the project containing the find modules set an internal cache variable, and to do
list (APPEND CMAKE_MODULE_PATH "${MY_PKG_MODULE_PATH}")
from the consuming project? This works, but seems ugly.