1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
# Copyright (C) 2022 by Pedro Mendes, Rector and Visitors of the
# University of Virginia, University of Heidelberg, and University
# of Connecticut School of Medicine.
# All rights reserved.
# - Try to find the Zlib XML parsing library
# Once done this will define
#
# ZLIB_FOUND - system has Zlib
# ZLIB_LIBRARIES - Link these to use Zlib
# ZLIB_INCLUDE_DIR - Include directory for using Zlib
# ZLIB_DEFINITIONS - Compiler switches required for using Zlib
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO (FIND_ZLIB)
ENDMACRO ()
string(TOUPPER ${PROJECT_NAME} _UPPER_PROJECT_NAME)
set(_PROJECT_DEPENDENCY_DIR ${_UPPER_PROJECT_NAME}_DEPENDENCY_DIR)
# Check if we have cached results in case the last round was successful.
if (NOT (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY) OR NOT ZLIB_FOUND)
set(ZLIB_LDFLAGS)
find_path(ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h
PATHS $ENV{ZLIB_DIR}/include
$ENV{ZLIB_DIR}
${${_PROJECT_DEPENDENCY_DIR}}/include
~/Library/Frameworks
/Library/Frameworks
/sw/include # Fink
/opt/local/include # MacPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
NO_DEFAULT_PATH)
if (NOT ZLIB_INCLUDE_DIR)
find_path(ZLIB_INCLUDE_DIR zlib.h zlib/zlib.h)
endif ()
find_library(ZLIB_LIBRARY
NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a
PATHS $ENV{ZLIB_DIR}/lib
$ENV{ZLIB_DIR}/lib-dbg
$ENV{ZLIB_DIR}
${${_PROJECT_DEPENDENCY_DIR}}/${CMAKE_INSTALL_LIBDIR}
${${_PROJECT_DEPENDENCY_DIR}}
~/Library/Frameworks
/Library/Frameworks
/sw/lib # Fink
/opt/local/lib # MacPorts
/opt/csw/lib # Blastwave
/opt/lib
/usr/freeware/lib64
NO_DEFAULT_PATH)
if (NOT ZLIB_LIBRARY)
find_library(ZLIB_LIBRARY NAMES zdll.lib z zlib.lib libzlib zlib libzlib.a)
endif ()
if (NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(PC_ZLIB QUIET zlib)
message(VERBOSE "${PC_ZLIB_STATIC_LDFLAGS}")
if (PC_ZLIB_FOUND)
set(ZLIB_DEFINITIONS ${PC_ZLIB_CFLAGS_OTHER})
set(ZLIB_VERSION ${PC_ZLIB_VERSION} CACHE STRING "Zlib Version found" )
endif (PC_ZLIB_FOUND)
endif (NOT WIN32)
# make sure that we have a valid zip library
file(TO_CMAKE_PATH "${ZLIB_LIBRARY}" LIBZ_CMAKE_PATH)
include (CheckLibraryExists)
check_library_exists("${LIBZ_CMAKE_PATH}" "gzopen" "" LIBZ_CMAKE_PATH)
if(NOT LIBZ_FOUND_SYMBOL)
# this is odd, but on windows this check always fails! must be a
# bug in the current cmake version so for now only issue this
# warning on linux
if(UNIX)
message(WARNING
"The chosen zlib library does not appear to be valid because it is
missing certain required symbols. Please check that ${LIBZ_LIBRARY} is
the correct zlib library. For details about the error, please see
${LIBSBML_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log")
endif()
endif()
mark_as_advanced(ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
endif () # Check for cached values
# create an zlib target to link against
if(NOT TARGET ZLIB::ZLIB)
add_library(ZLIB::ZLIB UNKNOWN IMPORTED)
set_target_properties(ZLIB::ZLIB PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${ZLIB_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
ZLIB
VERSION_VAR ZLIB_VERSION
REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
mark_as_advanced(ZLIB_VERSION)
|