- Reset a few more variables used in FindXYZ scripts.
[obnox/wireshark/wip.git] / cmake / modules / FindZLIB.cmake
1 # - Find zlib
2 # Find the native ZLIB includes and library
3 #
4 #  $Id$
5 #
6 #  ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
7 #  ZLIB_LIBRARIES    - List of libraries when using zlib.
8 #  ZLIB_FOUND        - True if zlib found.
9
10 #=============================================================================
11 # Copyright 2001-2009 Kitware, Inc.
12 #
13 # Distributed under the OSI-approved BSD License (the "License");
14 # see accompanying file Copyright.txt for details.
15 #
16 # This software is distributed WITHOUT ANY WARRANTY; without even the
17 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # See the License for more information.
19 #=============================================================================
20 # (To distributed this file outside of CMake, substitute the full
21 #  License text for the above reference.)
22
23 IF (ZLIB_INCLUDE_DIR)
24   # Already in cache, be silent
25   SET(ZLIB_FIND_QUIETLY TRUE)
26 ENDIF (ZLIB_INCLUDE_DIR)
27
28 FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
29
30 SET(ZLIB_NAMES z zlib zdll)
31 FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} )
32 MARK_AS_ADVANCED( ZLIB_LIBRARY ZLIB_INCLUDE_DIR )
33
34 # Per-recommendation
35 SET(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}")
36 SET(ZLIB_LIBRARIES    "${ZLIB_LIBRARY}")
37
38 INCLUDE(CheckFunctionExists)
39 SET(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES})
40 CHECK_FUNCTION_EXISTS("gzclearerr" HAVE_GZCLEARERR)
41 # reset
42 SET(CMAKE_REQUIRED_LIBRARIES "")
43
44 # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if 
45 # all listed variables are TRUE
46 INCLUDE(FindPackageHandleStandardArgs)
47 FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS)
48