I have a project where FindZLIB used to return correct ZLIB_LIBRARY_RELEASE on 3.16.x (zlib1.dll), however starting with 3.17.x and further I’m getting:
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.7")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.17/Modules/FindZLIB.cmake:115 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
rts/lib/minizip/CMakeLists.txt:22 (find_package)
I’m building on Windows and use mingw environment to get executables.
Hmm… I was able to rectify the issue by setting: set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ${CMAKE_FIND_LIBRARY_SUFFIXES}) in my CMakeLists.txt overriding the standard set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") set in Windows-GNU.cmake.
I must say .dll.a is a very strange extension for mingw built libs. At the very least “.dll” should be added to the list too.
On Windows .dll is a runtime dependency. For linking you need .lib (MinGW uses .dll.a (dynamic lib) or .a (static lib) for that). Those are correct extensions to look for for linking.