@@ -42,11 +42,12 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
4242 NO_DEFAULT_PATH)
4343
4444 if (NOT ZLIB_INCLUDE_DIR)
45- find_path (ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h)
45+ find_path (ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h
46+ CMAKE_FIND_ROOT_PATH_BOTH )
4647 endif ()
4748
4849 find_library (ZLIB_LIBRARY
49- NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a
50+ NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a libzdll.a
5051 PATHS $ENV{ZLIB_DIR} /lib
5152 $ENV{ZLIB_DIR} /lib-dbg
5253 $ENV{ZLIB_DIR}
@@ -62,7 +63,8 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
6263 NO_DEFAULT_PATH)
6364
6465 if (NOT ZLIB_LIBRARY)
65- find_library (ZLIB_LIBRARY NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a)
66+ find_library (ZLIB_LIBRARY NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a libzdll.a
67+ CMAKE_FIND_ROOT_PATH_BOTH )
6668 endif ()
6769
6870 if (NOT WIN32 )
@@ -77,6 +79,24 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
7779 endif (PC_ZLIB_FOUND)
7880 endif (NOT WIN32 )
7981
82+
83+ # make sure that we have a valid zip library
84+ file (TO_CMAKE_PATH "${ZLIB_LIBRARY} " LIBZ_CMAKE_PATH)
85+ include (CheckLibraryExists)
86+ check_library_exists("${LIBZ_CMAKE_PATH} " "gzopen" "" LIBZ_CMAKE_PATH)
87+ if (NOT LIBZ_FOUND_SYMBOL)
88+ # this is odd, but on windows this check always fails! must be a
89+ # bug in the current cmake version so for now only issue this
90+ # warning on linux
91+ if (UNIX )
92+ message (WARNING
93+ "The chosen zlib library does not appear to be valid because it is
94+ missing certain required symbols. Please check that ${LIBZ_LIBRARY} is
95+ the correct zlib library. For details about the error, please see
96+ ${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /CMakeError.log" )
97+ endif ()
98+ endif ()
99+
80100 mark_as_advanced (ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
81101
82102endif () # Check for cached values
0 commit comments