Missing error message if FetchContent_MakeAvailable() does not provide the dependency due to FETCHCONTENT_FULLY_DISCONNECTED
Hello,
When using FETCHCONTENT_FULLY_DISCONNECTED=ON
, the download is disabled and there currently does not seem to be any error message if the dependency is not actually provided in another way (such as FETCHCONTENT_SOURCE_DIR_*
or FETCHCONTENT_TRY_FIND_PACKAGE_MODE
). The documentation says that it is assumed to be provided, but it could be helpful to show an error if that is not the case, to avoid subsequent errors/problems in the project due to the missing targets/variables/files.
This would be useful for me for packaging projects with many dependencies in build environments such as Yocto recipes, which need to use FETCHCONTENT_FULLY_DISCONNECTED=ON
by default always.
Or is there already a way to do this?
I have tried FetchContent_Declare(... FIND_PACKAGE_ARGS REQUIRED)
, but the problem then is that it always requires find_package
and does not fallback to the download anymore (which is still wanted for the project when built outside Yocto), unless the default FETCHCONTENT_TRY_FIND_PACKAGE_MODE
value is overridden from OPT_IN
to NEVER
, or generator expressions are used to make it depend on FETCHCONTENT_FULLY_DISCONNECTED
and FETCHCONTENT_TRY_FIND_PACKAGE_MODE
. But these options seem too convoluted.
There also is CMAKE_REQUIRE_FIND_PACKAGE_*
, which would help in making the find_package
REQUIRED
in special build environments, but at the same time it's inconvenient, because it requires knowing the exact list of dependencies. So it doesn't seem to help in discovering missing dependencies either.