1- # Copyright (C) 2022 by Pedro Mendes, Rector and Visitors of the
1+ # Copyright (C) 2022 - 2023 by Pedro Mendes, Rector and Visitors of the
22# University of Virginia, University of Heidelberg, and University
33# of Connecticut School of Medicine.
44# All rights reserved.
@@ -31,38 +31,43 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
3131 find_path (ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h
3232 PATHS $ENV{ZLIB_DIR} /include
3333 $ENV{ZLIB_DIR}
34- ${${_PROJECT_DEPENDENCY_DIR}}/include
34+ ${${_PROJECT_DEPENDENCY_DIR}}/include
3535 ~/Library/Frameworks
3636 /Library/Frameworks
3737 /sw/include # Fink
3838 /opt/local/include # MacPorts
3939 /opt/csw/include # Blastwave
4040 /opt/include
4141 /usr/freeware/include
42- NO_DEFAULT_PATH )
42+ CMAKE_FIND_ROOT_PATH_BOTH
43+ NO_DEFAULT_PATH )
4344
4445 if (NOT ZLIB_INCLUDE_DIR)
45- find_path (ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h )
46+ find_path (ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h
47+ CMAKE_FIND_ROOT_PATH_BOTH )
4648 endif ()
4749
4850 find_library (ZLIB_LIBRARY
49- NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a
51+ NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a libzdll.a
5052 PATHS $ENV{ZLIB_DIR} /lib
5153 $ENV{ZLIB_DIR} /lib-dbg
5254 $ENV{ZLIB_DIR}
53- ${${_PROJECT_DEPENDENCY_DIR}}/${CMAKE_INSTALL_LIBDIR}
54- ${${_PROJECT_DEPENDENCY_DIR}}
55+ ${${_PROJECT_DEPENDENCY_DIR}}/${CMAKE_INSTALL_LIBDIR}
56+ ${${_PROJECT_DEPENDENCY_DIR}}/lib
57+ ${${_PROJECT_DEPENDENCY_DIR}}
5558 ~/Library/Frameworks
5659 /Library/Frameworks
5760 /sw/lib # Fink
5861 /opt/local/lib # MacPorts
5962 /opt/csw/lib # Blastwave
6063 /opt/lib
6164 /usr/freeware/lib64
65+ CMAKE_FIND_ROOT_PATH_BOTH
6266 NO_DEFAULT_PATH )
6367
6468 if (NOT ZLIB_LIBRARY)
65- find_library (ZLIB_LIBRARY NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a )
69+ find_library (ZLIB_LIBRARY NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a libzdll.a
70+ CMAKE_FIND_ROOT_PATH_BOTH )
6671 endif ()
6772
6873 if (NOT WIN32 )
@@ -77,6 +82,24 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
7782 endif (PC_ZLIB_FOUND )
7883 endif (NOT WIN32 )
7984
85+
86+ # make sure that we have a valid zip library
87+ file (TO_CMAKE_PATH "${ZLIB_LIBRARY} " LIBZ_CMAKE_PATH )
88+ include (CheckLibraryExists )
89+ check_library_exists ("${LIBZ_CMAKE_PATH} " "gzopen" "" LIBZ_CMAKE_PATH )
90+ if (NOT LIBZ_FOUND_SYMBOL)
91+ # this is odd, but on windows this check always fails! must be a
92+ # bug in the current cmake version so for now only issue this
93+ # warning on linux
94+ if (UNIX )
95+ message (WARNING
96+ "The chosen zlib library does not appear to be valid because it is
97+ missing certain required symbols. Please check that ${LIBZ_LIBRARY} is
98+ the correct zlib library. For details about the error, please see
99+ ${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /CMakeError.log" )
100+ endif ()
101+ endif ()
102+
80103 mark_as_advanced (ZLIB_INCLUDE_DIR ZLIB_LIBRARY )
81104
82105endif () # Check for cached values
0 commit comments