Target "png_shared" links to:
ZLIB::ZLIB
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
After the instructions about zlib, I added the command : message("ZLib found ? ${ZLIB_FOUND}")
which confirmed me that ZLib was not found, because ${ZLIB_FOUND} doesn’t exist.
Note that if I use FIND_PACKAGE_ARGS, ${ZLIB_FOUND} doest exist, but its value is false.
I don’t understand why there are two different behaviors…
Zlib seems to have many troubles with CMake :
For now, I suppose FindZLIB() is called at one moment, and I see in its documentation that we can set ZLIB_ROOT to help it.
Zlib has been downloaded, and put in the build directory, in a subdirectory called _deps.
Then, there are three directories, alongside with three other ones related to libpng. The three directories are :
zlib-build
zlib-src
zlib-subbuild
So :
Am I right to think setting ZLIB_ROOT could help me ?
If so, where to put the instruction, and what value should I give to it ?
Thanks.
EDIT : I commented all the code above, but I kept the ZLIB build. Then I added the follwing instructions :
set(ZLIB_ROOT ${CMAKE_BINARY_DIR}/_deps/zlib-build)
message("${CMAKE_BINARY_DIR}/_deps/zlib-build")
find_package("zlib")
message("ZLib found ? ${ZLIB_FOUND}")
But zlib is not found yet, whereas the path seems to be good…
PS: Any other hint to help me to resolve my zlib troubles is welcome…
If you want this to try using the CMake-provided FindZLIB module first, that should be just FIND_PACKAGE_ARGS NAMES ZLIB. The capitalisation of ZLIB in this line also matters because it needs to match up with the capitalisation of FindZLIB.
I will say that trying to get any sort of CMake-related changes into the official zlib repository has been a fruitless task. Many have tried, but the maintainer has shown essentially zero interest. Others have tried setting up a better maintained fork, but I haven’t seen any that have gained widespread adoption. This is a really unfortunate situation, given that zlib is such a widely used, foundational dependency of so many other things. This means trying to bring it in using FetchContent is usually a frustrating experience. You will likely end up having to set up your own fork with the patches you need to get things to work. Normally I’d say just use a package manager and be done with it, but you’ve stated up front that isn’t an option for you.