Warning, /network/libktorrent/cmake/FindLibGcrypt.cmake is written in an unsupported language. File is not indexed.

0001 #.rst:
0002 # FindLibGcrypt
0003 # -------------
0004 #
0005 # Try to find libgcrypt.
0006 #
0007 # This will define the following variables:
0008 #
0009 # ``LibGcrypt_FOUND``
0010 #     True if libgcrypt is available.
0011 #
0012 # ``LibGcrypt_VERSION``
0013 #     The version of LibGcrypt
0014 #
0015 # ``LibGcrypt_INCLUDE_DIRS``
0016 #     This should be passed to target_include_directories() if
0017 #     the target is not used for linking
0018 #
0019 # ``LibGcrypt_LIBRARIES``
0020 #     This can be passed to target_link_libraries() instead of
0021 #     the ``LibGcrypt::LibGcrypt`` target
0022 #
0023 # If ``LibGcrypt_FOUND`` is TRUE, the following imported target
0024 # will be available:
0025 #
0026 # ``LibGcrypt::LibGcrypt``
0027 #     The libgcrypt library
0028 #
0029 # Since 1.9.50.
0030 
0031 #=============================================================================
0032 # This was based upon FindKopete.cmake:
0033 # SPDX-FileCopyrightText: 2007 Charles Connell <charles@connells.org>
0034 #
0035 # SPDX-FileCopyrightText: 2010 Joris Guisson <joris.guisson@gmail.com>
0036 # SPDX-FileCopyrightText: 2016 Christophe Giboudeaux <cgiboudeaux@gmx.com>
0037 #
0038 # SPDX-License-Identifier: BSD-3-Clause
0039 #=============================================================================
0040 
0041 find_path(LibGcrypt_INCLUDE_DIRS
0042     NAMES gcrypt.h
0043     PATH_SUFFIXES libgcrypt
0044 )
0045 
0046 find_library(LibGcrypt_LIBRARIES
0047     NAMES gcrypt
0048 )
0049 
0050 if(MSVC)
0051     find_library(LibGcrypt_LIBRARIES_DEBUG
0052         NAMES gcryptd
0053     )
0054 
0055     if(NOT LibGcrypt_LIBRARIES_DEBUG)
0056         unset(LibGcrypt_LIBRARIES CACHE)
0057     endif()
0058 
0059     if(MSVC_IDE)
0060         if(NOT (LibGcrypt_LIBRARIES_DEBUG AND LibGcrypt_LIBRARIES))
0061             message(STATUS
0062                 "\nCould NOT find the debug AND release version of the libgcrypt library.\n
0063                 You need to have both to use MSVC projects.\n
0064                 Please build and install both libgcrypt libraries first.\n"
0065             )
0066             unset(LibGcrypt_LIBRARIES CACHE)
0067         endif()
0068     else()
0069         string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
0070         if(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
0071             set(LibGcrypt_LIBRARIES ${LibGcrypt_LIBRARIES_DEBUG})
0072         endif()
0073     endif()
0074 endif()
0075 
0076 # Get version from gcrypt.h
0077 # #define GCRYPT_VERSION "1.6.4"
0078 if(LibGcrypt_INCLUDE_DIRS AND LibGcrypt_LIBRARIES)
0079     file(STRINGS ${LibGcrypt_INCLUDE_DIRS}/gcrypt.h _GCRYPT_H REGEX "^#define GCRYPT_VERSION[ ]+.*$")
0080     string(REGEX REPLACE "^.*GCRYPT_VERSION[ ]+\"([0-9]+).([0-9]+).([0-9]+).*\".*$" "\\1" LibGcrypt_MAJOR_VERSION "${_GCRYPT_H}")
0081     string(REGEX REPLACE "^.*GCRYPT_VERSION[ ]+\"([0-9]+).([0-9]+).([0-9]+).*\".*$" "\\2" LibGcrypt_MINOR_VERSION "${_GCRYPT_H}")
0082     string(REGEX REPLACE "^.*GCRYPT_VERSION[ ]+\"([0-9]+).([0-9]+).([0-9]+).*\".*$" "\\3" LibGcrypt_PATCH_VERSION "${_GCRYPT_H}")
0083 
0084     set(LibGcrypt_VERSION "${LibGcrypt_MAJOR_VERSION}.${LibGcrypt_MINOR_VERSION}.${LibGcrypt_PATCH_VERSION}")
0085     unset(_GCRYPT_H)
0086 endif()
0087 
0088 include(FindPackageHandleStandardArgs)
0089 find_package_handle_standard_args(LibGcrypt
0090     FOUND_VAR LibGcrypt_FOUND
0091     REQUIRED_VARS LibGcrypt_INCLUDE_DIRS LibGcrypt_LIBRARIES
0092     VERSION_VAR LibGcrypt_VERSION
0093 )
0094 
0095 if(LibGcrypt_FOUND AND NOT TARGET LibGcrypt::LibGcrypt)
0096     add_library(LibGcrypt::LibGcrypt UNKNOWN IMPORTED)
0097     set_target_properties(LibGcrypt::LibGcrypt PROPERTIES
0098         IMPORTED_LOCATION "${LibGcrypt_LIBRARIES}"
0099         INTERFACE_INCLUDE_DIRECTORIES "${LibGcrypt_INCLUDE_DIRS}")
0100 endif()
0101 
0102 mark_as_advanced(LibGcrypt_INCLUDE_DIRS LibGcrypt_LIBRARIES)
0103 
0104 include(FeatureSummary)
0105 set_package_properties(LibGcrypt PROPERTIES
0106     URL "http://directory.fsf.org/wiki/Libgcrypt"
0107     DESCRIPTION "General purpose crypto library based on the code used in GnuPG."
0108 )