How do I integrate zlib with my build?

zlib is built with cmake, and if I add_subdirectory it, it generates a required header zconf.h which it puts in the binary dir. Other projects that depend on zlib like libpng ask for the include dir of zlib (Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)), but what am I supposed to give it if zlib’s headers are split across its source dir and binary dir?

Using add_subdirectory for a dependency means that find_package() for that dependency should not be done. I think you may want to investigate the FetchContent module instead.

Cc: @craig.scott

I’m using the FetchContent module. As far as I know from reading the docs though, FetchContent just does add_subdirectory.

If you need to pass it around and have some other modules that depend on it, then quite possibly a superbuild with ExternalProject + find_package would be better for you.

Mixing FetchContent with find_package() for the same dependency isn’t really a supported scenario right now. The change in MR 5688 would provide that capability, but it has been put on hold for now (the associated issue has a much longer discussion).