FindGnuTLS.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. # Copyright 2009 Kitware, Inc.
  11. # Copyright 2009 Philip Lowman <[email protected]>
  12. # Copyright 2009 Brad Hards <[email protected]>
  13. # Copyright 2006 Alexander Neundorf <[email protected]>
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  18. # This software is distributed WITHOUT ANY WARRANTY; without even the
  19. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. # See the License for more information.
  21. #=============================================================================
  22. # (To distribute this file outside of CMake, substitute the full
  23. # License text for the above reference.)
  24. # Note that this doesn't try to find the gnutls-extra package.
  25. if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)
  26. # in cache already
  27. set(gnutls_FIND_QUIETLY TRUE)
  28. endif ()
  29. if (NOT WIN32)
  30. # try using pkg-config to get the directories and then use these values
  31. # in the find_path() and find_library() calls
  32. # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
  33. find_package(PkgConfig QUIET)
  34. PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
  35. set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
  36. set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
  37. endif ()
  38. find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h
  39. HINTS
  40. ${PC_GNUTLS_INCLUDEDIR}
  41. ${PC_GNUTLS_INCLUDE_DIRS}
  42. )
  43. find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls
  44. HINTS
  45. ${PC_GNUTLS_LIBDIR}
  46. ${PC_GNUTLS_LIBRARY_DIRS}
  47. )
  48. mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
  49. # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if
  50. # all listed variables are TRUE
  51. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  52. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
  53. REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR
  54. VERSION_VAR GNUTLS_VERSION_STRING)
  55. if(GNUTLS_FOUND)
  56. set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
  57. set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
  58. endif()