FindGnuTLS.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # FindGnuTLS
  5. # ----------
  6. #
  7. # Try to find the GNU Transport Layer Security library (gnutls)
  8. #
  9. #
  10. #
  11. # Once done this will define
  12. #
  13. # ::
  14. #
  15. # GNUTLS_FOUND - System has gnutls
  16. # GNUTLS_INCLUDE_DIR - The gnutls include directory
  17. # GNUTLS_LIBRARIES - The libraries needed to use gnutls
  18. # GNUTLS_DEFINITIONS - Compiler switches required for using gnutls
  19. # Note that this doesn't try to find the gnutls-extra package.
  20. if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)
  21. # in cache already
  22. set(gnutls_FIND_QUIETLY TRUE)
  23. endif ()
  24. if (NOT WIN32)
  25. # try using pkg-config to get the directories and then use these values
  26. # in the find_path() and find_library() calls
  27. # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
  28. find_package(PkgConfig QUIET)
  29. PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
  30. set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
  31. set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
  32. endif ()
  33. find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h
  34. HINTS
  35. ${PC_GNUTLS_INCLUDEDIR}
  36. ${PC_GNUTLS_INCLUDE_DIRS}
  37. )
  38. find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls
  39. HINTS
  40. ${PC_GNUTLS_LIBDIR}
  41. ${PC_GNUTLS_LIBRARY_DIRS}
  42. )
  43. mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
  44. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  45. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
  46. REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR
  47. VERSION_VAR GNUTLS_VERSION_STRING)
  48. if(GNUTLS_FOUND)
  49. set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
  50. set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
  51. endif()