FindGnuTLS.cmake 2.4 KB

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