Skip to content

Commit a194c5a

Browse files
committed
- use common find module for zlib
1 parent 54bf4d3 commit a194c5a

File tree

5 files changed

+95
-15
lines changed

5 files changed

+95
-15
lines changed

src/libCombine/CMakeModules/FindZLIB.cmake

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
4747
endif ()
4848

4949
find_library(ZLIB_LIBRARY
50-
NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a
50+
NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a libzdll.a
5151
PATHS $ENV{ZLIB_DIR}/lib
5252
$ENV{ZLIB_DIR}/lib-dbg
5353
$ENV{ZLIB_DIR}
@@ -63,7 +63,7 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
6363
NO_DEFAULT_PATH)
6464

6565
if (NOT ZLIB_LIBRARY)
66-
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
6767
CMAKE_FIND_ROOT_PATH_BOTH )
6868
endif ()
6969

@@ -79,6 +79,24 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
7979
endif (PC_ZLIB_FOUND)
8080
endif (NOT WIN32)
8181

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+
82100
mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
83101

84102
endif () # Check for cached values

src/libSBML/CMakeModules/FindZLIB.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -76,7 +78,8 @@ if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
7678
set(ZLIB_VERSION ${PC_ZLIB_VERSION} CACHE STRING "Zlib Version found" )
7779
endif (PC_ZLIB_FOUND)
7880
endif (NOT WIN32)
79-
81+
82+
8083
# make sure that we have a valid zip library
8184
file(TO_CMAKE_PATH "${ZLIB_LIBRARY}" LIBZ_CMAKE_PATH)
8285
include (CheckLibraryExists)
@@ -94,7 +97,6 @@ ${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log")
9497
endif()
9598
endif()
9699

97-
98100
mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
99101

100102
endif () # Check for cached values

src/libSEDML/CMakeModules/FindZLIB.cmake

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

82102
endif () # Check for cached values

src/libnuml/CMakeModules/FindZLIB.cmake

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

82102
endif () # Check for cached values

src/zipper/CMakeModules/FindZLIB.cmake

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ 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
@@ -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 libzdll.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

82102
endif () # Check for cached values

0 commit comments

Comments
 (0)