Skip to content

Commit 65796a2

Browse files
committed
- fix zlib detection
1 parent 429139b commit 65796a2

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

CMakeModules/FindZLIB.cmake

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2022 by Pedro Mendes, Rector and Visitors of the
1+
# Copyright (C) 2022 - 2025 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)
@@ -76,11 +81,12 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
7681
set(ZLIB_VERSION ${PC_ZLIB_VERSION} CACHE STRING "Zlib Version found" )
7782
endif (PC_ZLIB_FOUND)
7883
endif (NOT WIN32)
79-
84+
85+
8086
# make sure that we have a valid zip library
8187
file(TO_CMAKE_PATH "${ZLIB_LIBRARY}" LIBZ_CMAKE_PATH)
8288
include (CheckLibraryExists)
83-
check_library_exists("${LIBZ_CMAKE_PATH}" "gzopen" "" LIBZ_CMAKE_PATH)
89+
check_library_exists("${LIBZ_CMAKE_PATH}" "gzopen" "" LIBZ_FOUND_SYMBOL)
8490
if(NOT LIBZ_FOUND_SYMBOL)
8591
# this is odd, but on windows this check always fails! must be a
8692
# bug in the current cmake version so for now only issue this
@@ -90,11 +96,10 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
9096
"The chosen zlib library does not appear to be valid because it is
9197
missing certain required symbols. Please check that ${LIBZ_LIBRARY} is
9298
the correct zlib library. For details about the error, please see
93-
${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log")
99+
CMakeError.log or CMakeConfigureLog.yaml in the build directory.")
94100
endif()
95101
endif()
96102

97-
98103
mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
99104

100105
endif () # Check for cached values

0 commit comments

Comments
 (0)