Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindGnuTLS.cmake
1 # - Try to find the GNU Transport Layer Security library (gnutls)
2 #
3 # Once done this will define
4 #
5 #  GNUTLS_FOUND - System has gnutls
6 #  GNUTLS_INCLUDE_DIR - The gnutls include directory
7 #  GNUTLS_LIBRARIES - The libraries needed to use gnutls
8 #  GNUTLS_DEFINITIONS - Compiler switches required for using gnutls
9
10 #=============================================================================
11 # Copyright 2009 Kitware, Inc.
12 # Copyright 2009 Philip Lowman <philip@yhbt.com>
13 # Copyright 2009 Brad Hards <bradh@kde.org>
14 # Copyright 2006 Alexander Neundorf <neundorf@kde.org>
15 #
16 # Distributed under the OSI-approved BSD License (the "License");
17 # see accompanying file Copyright.txt for details.
18 #
19 # This software is distributed WITHOUT ANY WARRANTY; without even the
20 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 # See the License for more information.
22 #=============================================================================
23 # (To distribute this file outside of CMake, substitute the full
24 #  License text for the above reference.)
25
26 # Note that this doesn't try to find the gnutls-extra package.
27
28
29 if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)
30    # in cache already
31    set(gnutls_FIND_QUIETLY TRUE)
32 endif ()
33
34 if (NOT WIN32)
35    # try using pkg-config to get the directories and then use these values
36    # in the find_path() and find_library() calls
37    # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
38    find_package(PkgConfig QUIET)
39    PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
40    set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
41    set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
42 endif ()
43
44 find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h
45    HINTS
46    ${PC_GNUTLS_INCLUDEDIR}
47    ${PC_GNUTLS_INCLUDE_DIRS}
48    )
49
50 find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls
51    HINTS
52    ${PC_GNUTLS_LIBDIR}
53    ${PC_GNUTLS_LIBRARY_DIRS}
54    )
55
56 mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
57
58 # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if
59 # all listed variables are TRUE
60 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
61 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
62                                   REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR
63                                   VERSION_VAR GNUTLS_VERSION_STRING)
64
65 if(GNUTLS_FOUND)
66     set(GNUTLS_LIBRARIES    ${GNUTLS_LIBRARY})
67     set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
68 endif()
69