File: FindZLIB.cmake

package info (click to toggle)
gfal2 2.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,452 kB
  • sloc: ansic: 15,858; cpp: 15,198; python: 257; sh: 228; makefile: 120
file content (58 lines) | stat: -rw-r--r-- 1,888 bytes parent folder | download | duplicates (2)
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
#
# This module detects if zlib is installed and determines where the
# include files and libraries are.
#
# This code sets the following variables:
#
# ZLIB_LIBRARIES       = full path to the zlib libraries
# ZLIB_INCLUDE_DIR     = include dir to be used when using the glib2 library
# ZLIB_FOUND           = set to true if zlib was found successfully
#
# ZLIB_LOCATION
#   setting this enables search for zlib libraries / headers in this location

find_package (PkgConfig)
pkg_check_modules(ZLIB_PKG zlib)

if (ZLIB_PKG_FOUND)
    set (ZLIB_LIBRARIES ${ZLIB_PKG_LIBRARIES})
    set (ZLIB_INCLUDE_DIRS ${ZLIB_PKG_INCLUDE_DIRS})
    if (NOT ZLIB_INCLUDE_DIRS)
        set (ZLIB_INCLUDE_DIRS "/usr/include")
    endif (NOT ZLIB_INCLUDE_DIRS)
    set (ZLIB_DEFINITIONS "${ZLIB_PKG_CFLAGS} ${ZLIB_PKG_CFLAGS_OTHER}")
else (ZLIB_PKG_FOUND)

    find_library(ZLIB_LIBRARIES
        NAMES zlib
        HINTS ${ZLIB_LOCATION}
              ${CMAKE_INSTALL_PREFIX}/zlib/*/${PLATFORM}/
        DOC "The main glib2 library"
    )

    find_path(ZLIB_INCLUDE_DIRS
        NAMES zlib.h
        HINTS ${ZLIB_LOCATION}/include/*
              ${CMAKE_INSTALL_PREFIX}/zlib/*/${PLATFORM}/
        DOC "The glib2 include directory"
    )

    set (ZLIB_DEFINITIONS "")
endif (ZLIB_PKG_FOUND)

if (ZLIB_LIBRARIES)
    message (STATUS "ZLIB libraries: ${ZLIB_LIBRARIES}")
endif (ZLIB_LIBRARIES)
if (ZLIB_INCLUDE_DIRS)
    message (STATUS "ZLIB include dir: ${ZLIB_INCLUDE_DIRS}")
endif (ZLIB_INCLUDE_DIRS)

# -----------------------------------------------------
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
# all listed variables are TRUE
# -----------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args (ZLIB DEFAULT_MSG
    ZLIB_LIBRARIES  ZLIB_INCLUDE_DIRS
)
mark_as_advanced(ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)