FindGnuTLS.cmake 2.42 KB
Newer Older
1 2 3 4 5 6 7
#.rst:
# FindGnuTLS
# ----------
#
# Try to find the GNU Transport Layer Security library (gnutls)
#
#
8 9 10
#
# Once done this will define
#
11 12 13 14 15 16
# ::
#
#   GNUTLS_FOUND - System has gnutls
#   GNUTLS_INCLUDE_DIR - The gnutls include directory
#   GNUTLS_LIBRARIES - The libraries needed to use gnutls
#   GNUTLS_DEFINITIONS - Compiler switches required for using gnutls
17

18 19 20 21 22
#=============================================================================
# Copyright 2009 Kitware, Inc.
# Copyright 2009 Philip Lowman <philip@yhbt.com>
# Copyright 2009 Brad Hards <bradh@kde.org>
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
23
#
24 25
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
26
#
27 28 29 30
# 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.
#=============================================================================
31
# (To distribute this file outside of CMake, substitute the full
32 33
#  License text for the above reference.)

34 35 36
# Note that this doesn't try to find the gnutls-extra package.


37
if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)
38
   # in cache already
39
   set(gnutls_FIND_QUIETLY TRUE)
40
endif ()
41

42
if (NOT WIN32)
43
   # try using pkg-config to get the directories and then use these values
44
   # in the find_path() and find_library() calls
45
   # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
46
   find_package(PkgConfig QUIET)
47
   PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
48 49
   set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
   set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
50
endif ()
51

52
find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h
53 54 55 56 57
   HINTS
   ${PC_GNUTLS_INCLUDEDIR}
   ${PC_GNUTLS_INCLUDE_DIRS}
   )

58
find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls
59 60 61 62 63
   HINTS
   ${PC_GNUTLS_LIBDIR}
   ${PC_GNUTLS_LIBRARY_DIRS}
   )

64
mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
65

66
# handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if
67
# all listed variables are TRUE
68
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
69 70 71
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
                                  REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR
                                  VERSION_VAR GNUTLS_VERSION_STRING)
72

73 74 75 76
if(GNUTLS_FOUND)
    set(GNUTLS_LIBRARIES    ${GNUTLS_LIBRARY})
    set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
endif()
77