2
2
# Once done this will define
4
# ZLIB_ROOT_DIR - Set this variable to the root installation of ZLIB
4
7
# ZLIB_FOUND - system has ZLIB
5
8
# ZLIB_INCLUDE_DIRS - the ZLIB include directory
6
9
# ZLIB_LIBRARIES - Link these to use ZLIB
7
# ZLIB_DEFINITIONS - Compiler switches required for using ZLIB
9
# Copyright (c) 2009 Andreas Schneider <mail@cynapses.org>
11
# Redistribution and use is allowed according to the terms of the New
13
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
11
# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
12
# ZLIB_VERSION_MAJOR - The major version of zlib
13
# ZLIB_VERSION_MINOR - The minor version of zlib
14
# ZLIB_VERSION_PATCH - The patch version of zlib
15
# ZLIB_VERSION_TWEAK - The tweak version of zlib
17
# The following variable are provided for backward compatibility
19
# ZLIB_MAJOR_VERSION - The major version of zlib
20
# ZLIB_MINOR_VERSION - The minor version of zlib
21
# ZLIB_PATCH_VERSION - The patch version of zlib
23
#=============================================================================
24
# Copyright (c) 2001-2009 Kitware, Inc.
25
# Copyright (c) 2011 Andreas Schneider <asn@cryptomilk.org>
27
# Distributed under the OSI-approved BSD License (the "License");
28
# see accompanying file Copyright.txt for details.
30
# This software is distributed WITHOUT ANY WARRANTY; without even the
31
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
32
# See the License for more information.
33
#=============================================================================
17
36
if (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
19
38
set(ZLIB_FOUND TRUE)
20
39
else (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
22
set(_ZLIB_DIR $ENV{PROGRAMFILES}/GnuWin32)
25
find_path(ZLIB_INCLUDE_DIR
35
mark_as_advanced(ZLIB_INCLUDE_DIR)
37
find_library(Z_LIBRARY
49
mark_as_advanced(Z_LIBRARY)
66
if (ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES)
68
endif (ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES)
71
if (NOT ZLIB_FIND_QUIETLY)
72
message(STATUS "Found ZLIB: ${ZLIB_LIBRARIES}")
73
endif (NOT ZLIB_FIND_QUIETLY)
75
if (ZLIB_FIND_REQUIRED)
76
message(FATAL_ERROR "Could not find ZLIB")
77
endif (ZLIB_FIND_REQUIRED)
80
# show the ZLIB_INCLUDE_DIRS and ZLIB_LIBRARIES variables only in the advanced view
81
mark_as_advanced(ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)
42
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include"
46
"$ENV{PROGRAMFILES}/zlib"
49
find_path(ZLIB_ROOT_DIR
57
mark_as_advanced(ZLIB_ROOT_DIR)
59
# check for header file
60
find_path(ZLIB_INCLUDE_DIR
68
${ZLIB_ROOT_DIR}/include
70
mark_as_advanced(ZLIB_INCLUDE_DIR)
72
# check version number
73
if (ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
74
file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$")
76
string(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}")
77
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}")
78
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}")
80
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}")
82
# only append a TWEAK version if it exists:
83
set(ZLIB_VERSION_TWEAK "")
84
if ("${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
85
set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
86
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
87
endif ("${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
89
set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
90
set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
91
set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
92
endif (ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
94
find_library(ZLIB_LIBRARY
108
mark_as_advanced(ZLIB_LIBRARY)
110
include(FindPackageHandleStandardArgs)
111
find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
112
#find_package_handle_standard_args(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY
113
# VERSION_VAR ZLIB_VERSION_STRING)
116
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
117
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
83
119
endif (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)