Interaction between `find_dependency` and `CMAKE_DISABLE_FIND_PACKAGE_<PKG>`
I have a complaint that the CMake config files for Boost use find_package(ZLIB REQUIRED)
, which is impossible to override with CMAKE_DISABLE_FIND_PACKAGE_ZLIB
.
But the config files actually use find_dependency(ZLIB)
, which I thought was established practice.
The complaint seems legitimate to me. In a discussion it was suggested that find_dependency
is not to be used; the proposed alternative was find_package(ZLIB)
, and then checking ZLIB_FOUND
manually. But this doesn't seem right to me. If this is what config files ought to be doing, then the macro find_dependency
should do it, not everyone hardcoding it.
Alternatively, maybe there's nothing wrong with find_dependency
as is, and the problem is that CMAKE_DISABLE_FIND_PACKAGE_ZLIB
cannot override find_package(ZLIB REQUIRED)
. Intuitively, this seems like something that should work, provided that ZLIB_FOUND
is set to TRUE
(as it will be by whoever set CMAKE_DISABLE_FIND_PACKAGE_ZLIB
to TRUE
).