[Windows+CMake+custom ZLIB] Cannot build HDF5 with ZLIB support

There are a few similar topics, but I could not find help in them, so here is mine.

I am able to build HDF5 with the following toolchain
CMake-GUI + Visual Studio 2019/2022
I am familair with those tools, and I don’t have any problem to build HDF5 without Zlib support.

Now, I want to enable Zlib.
So I set HDF5_ENABLE_Z_LIB_SUPPORT to true
I have correctly filled ZLIB_DIR, ZLIB_INCLUDE_DIR, ZLIB_LIBRARY_DEBUG, ZLIB_LIBRARY_RELEASE, ZLIB_USE_EXTERNAL

But when trying to Configure, Cmake issues a warning
" ZLib support in HDF5 was enabled but not found"
and HDF5_ENABLE_Z_LIB_SUPPORT is reset to FALSE

Indeed, HDF5pubconf.h does not show any ZLIB support (H5_HAVE_ZLIB_H is disabled)

(see screen capture)

What could go wrong ?

Do not set ZLIB_USE_EXTERNAL = ON

Setting that ON indicates that you want to build ZLIB from source.

You are right, ZLIB_USE_EXTERNAL=OFF makes it work.

I was misleaded by the fact that usually, *_USE_INTERNAL states a built-in project dependency and *_USE_EXTERNAL will provide a custom build.

It has been noted that the naming is not ideal.