2005-12-14 21:51:08 +03:00
|
|
|
# - Find zlib
|
2010-07-31 09:24:47 +04:00
|
|
|
# Find the native ZLIB includes and library.
|
|
|
|
# Once done this will define
|
2002-09-03 00:24:25 +04:00
|
|
|
#
|
2010-04-11 12:29:20 +04:00
|
|
|
# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
|
|
|
|
# ZLIB_LIBRARIES - List of libraries when using zlib.
|
|
|
|
# ZLIB_FOUND - True if zlib found.
|
|
|
|
#
|
|
|
|
# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
|
2010-07-31 09:24:47 +04:00
|
|
|
# ZLIB_VERSION_MAJOR - The major version of zlib
|
|
|
|
# ZLIB_VERSION_MINOR - The minor version of zlib
|
|
|
|
# ZLIB_VERSION_PATCH - The patch version of zlib
|
|
|
|
# ZLIB_VERSION_TWEAK - The tweak version of zlib
|
|
|
|
#
|
|
|
|
# The following variable are provided for backward compatibility
|
|
|
|
#
|
|
|
|
# ZLIB_MAJOR_VERSION - The major version of zlib
|
2010-04-11 12:29:20 +04:00
|
|
|
# ZLIB_MINOR_VERSION - The minor version of zlib
|
|
|
|
# ZLIB_PATCH_VERSION - The patch version of zlib
|
2011-11-30 17:40:58 +04:00
|
|
|
#
|
|
|
|
# An includer may set ZLIB_ROOT to a zlib installation root to tell
|
|
|
|
# this module where to look.
|
2002-09-03 00:24:25 +04:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
2011-11-30 17:40:58 +04:00
|
|
|
# Copyright 2001-2011 Kitware, Inc.
|
2009-09-28 19:45:50 +04:00
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
2006-06-09 23:49:27 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_ZLIB_SEARCHES)
|
2011-11-30 17:40:58 +04:00
|
|
|
|
|
|
|
# Search ZLIB_ROOT first if it is set.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(ZLIB_ROOT)
|
|
|
|
set(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH)
|
|
|
|
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT)
|
|
|
|
endif()
|
2011-11-30 17:40:58 +04:00
|
|
|
|
|
|
|
# Normal search.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_ZLIB_SEARCH_NORMAL
|
2011-11-30 17:40:58 +04:00
|
|
|
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
|
|
|
|
"$ENV{PROGRAMFILES}/zlib"
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
|
2002-09-03 00:24:25 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1)
|
2011-11-30 17:40:58 +04:00
|
|
|
|
|
|
|
# Try each search configuration.
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(search ${_ZLIB_SEARCHES})
|
|
|
|
find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
|
|
|
|
find_library(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
|
|
|
|
endforeach()
|
2011-11-30 17:40:58 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
|
2009-10-30 19:17:25 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
|
|
|
|
file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$")
|
2010-07-31 09:24:47 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}")
|
|
|
|
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}")
|
|
|
|
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}")
|
|
|
|
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}")
|
2010-07-31 09:24:47 +04:00
|
|
|
|
2010-08-15 00:16:06 +04:00
|
|
|
# only append a TWEAK version if it exists:
|
2012-08-13 21:47:32 +04:00
|
|
|
set(ZLIB_VERSION_TWEAK "")
|
|
|
|
if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
|
|
|
|
set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
|
|
|
|
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2010-07-31 09:24:47 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
|
|
|
|
set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
|
|
|
|
set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
|
|
|
|
endif()
|
2010-04-11 12:29:20 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
|
2007-07-18 21:56:45 +04:00
|
|
|
# all listed variables are TRUE
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2011-04-07 20:22:24 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR
|
2010-08-04 10:18:05 +04:00
|
|
|
VERSION_VAR ZLIB_VERSION_STRING)
|
2010-07-31 09:24:47 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(ZLIB_FOUND)
|
|
|
|
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
|
|
|
|
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
|
|
|
|
endif()
|
2006-06-09 23:49:27 +04:00
|
|
|
|