summaryrefslogtreecommitdiffstats
path: root/cmake/Modules/FindZLIB.cmake
blob: 197e6c757b000db913684e50915e2f87031ebdc5 (plain)
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
# - Try to find ZLIB
# Once done this will define
#
#  ZLIB_FOUND - system has ZLIB
#  ZLIB_INCLUDE_DIRS - the ZLIB include directory
#  ZLIB_LIBRARIES - Link these to use ZLIB
#  ZLIB_DEFINITIONS - Compiler switches required for using ZLIB
#
#  Copyright (c) 2009-2010 Andreas Schneider <mail@cynapses.org>
#
#  Redistribution and use is allowed according to the terms of the New
#  BSD license.
#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


if (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
  # in cache already
  set(ZLIB_FOUND TRUE)
else (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
  if (WIN32)
    set(_ZLIB_DIR $ENV{PROGRAMFILES}/GnuWin32)
  endif (WIN32)

  find_path(ZLIB_INCLUDE_DIR
    NAMES
      zlib.h
    PATHS
      ${_ZLIB_DIR}/include
      /usr/include
      /usr/local/include
      /opt/local/include
      /sw/include
      /usr/lib/sfw/include
  )

  find_library(Z_LIBRARY
    NAMES
      z
      zlib
      zlib1
    PATHS
      ${_ZLIB_DIR}/lib
      /usr/lib
      /usr/local/lib
      /opt/local/lib
      /sw/lib
      /usr/sfw/lib/64
      /usr/sfw/lib
  )

  set(ZLIB_INCLUDE_DIRS
    ${ZLIB_INCLUDE_DIR}
  )

  if (Z_LIBRARY)
    set(ZLIB_LIBRARIES
        ${ZLIB_LIBRARIES}
        ${Z_LIBRARY}
    )
  endif (Z_LIBRARY)

  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS)

  # show the ZLIB_INCLUDE_DIRS and ZLIB_LIBRARIES variables only in the advanced view
  mark_as_advanced(ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)

endif (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)