Warning, /pim/kleopatra/cmake/modules/FindLibGpgError.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2022 g10 Code GmbH
0002 # SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005
0006 #[=======================================================================[.rst:
0007 FindLibGpgError
0008 ---------------
0009
0010 Try to find the Libgpg-error library.
0011
0012 This will define the following variables:
0013
0014 ``LibGpgError_FOUND``
0015 True if (the requested version of) Libgpg-error was found
0016 ``LibGpgError_VERSION``
0017 The version of the Libgpg-error library which was found
0018 ``LibGpgError_LIBRARIES``
0019 Libraries you need to link when using Libgpg-error This can be passed to
0020 target_link_libraries() instead of the ``LibGpgError::LibGpgError`` target.
0021 ``LibGpgError_INCLUDE_DIRS``
0022 Include directories needed to use Libgpg-error This should be passed to
0023 target_include_directories() if the target is not used for linking.
0024 ``LibGpgError_DEFINITIONS``
0025 Compile definitions to use when compiling code that uses Libgpg-error
0026 This should be passed to target_compile_options() if the target is not
0027 used for linking.
0028
0029 If ``LibGpgError_FOUND`` is TRUE, it will also define the following imported target:
0030
0031 ``LibGpgError::LibGpgError``
0032 The Libgpg-error library
0033
0034 #]=======================================================================]
0035
0036 find_package(PkgConfig QUIET)
0037 pkg_check_modules(PC_LibGpgError QUIET gpg-error)
0038
0039 set(LibGpgError_VERSION ${PC_LibGpgError_VERSION})
0040 set(LibGpgError_DEFINITIONS ${PC_LibGpgError_CFLAGS_OTHER})
0041
0042 find_path(LibGpgError_INCLUDE_DIR
0043 NAMES
0044 gpg-error.h
0045 PATHS
0046 ${PC_LibGpgError_INCLUDE_DIRS}
0047 )
0048 find_library(LibGpgError_LIBRARY
0049 NAMES
0050 gpg-error
0051 PATHS
0052 ${PC_LibGpgError_LIBRARY_DIRS}
0053 )
0054
0055 if(LibGpgError_INCLUDE_DIR AND NOT LibGpgError_VERSION)
0056 # The version is given in the format MAJOR.MINOR optionally followed
0057 # by an intermediate "beta" version given as -betaNUM, e.g. "1.47-beta7".
0058 file(STRINGS "${LibGpgError_INCLUDE_DIR}/gpg-error.h" LibGpgError_VERSION_STR
0059 REGEX "^#[\t ]*define[\t ]+GPG_ERROR_VERSION[\t ]+\"([0-9])+\\.([0-9])+(-[a-z0-9]*)?\".*")
0060 string(REGEX REPLACE "^.*GPG_ERROR_VERSION[\t ]+\"([0-9]+\\.[0-9]+(-[a-z0-9]*)?)\".*$"
0061 "\\1" LibGpgError_VERSION_STR "${LibGpgError_VERSION_STR}")
0062
0063 set(LibGpgError_VERSION "${LibGpgError_VERSION_STR}")
0064
0065 unset(LibGpgError_VERSION_STR)
0066 endif()
0067
0068 include(FindPackageHandleStandardArgs)
0069 find_package_handle_standard_args(LibGpgError
0070 REQUIRED_VARS
0071 LibGpgError_LIBRARY
0072 LibGpgError_INCLUDE_DIR
0073 LibGpgError_VERSION
0074 VERSION_VAR
0075 LibGpgError_VERSION
0076 )
0077
0078 if(LibGpgError_FOUND AND NOT TARGET LibGpgError::LibGpgError)
0079 add_library(LibGpgError::LibGpgError UNKNOWN IMPORTED)
0080 set_target_properties(LibGpgError::LibGpgError PROPERTIES
0081 IMPORTED_LOCATION "${LibGpgError_LIBRARY}"
0082 INTERFACE_COMPILE_OPTIONS "${LibGpgError_DEFINITIONS}"
0083 INTERFACE_INCLUDE_DIRECTORIES "${LibGpgError_INCLUDE_DIR}"
0084 )
0085 endif()
0086
0087 mark_as_advanced(
0088 LibGpgError_INCLUDE_DIR
0089 LibGpgError_LIBRARY
0090 )
0091
0092 if(LibGpgError_FOUND)
0093 set(LibGpgError_LIBRARIES ${LibGpgError_LIBRARY})
0094 set(LibGpgError_INCLUDE_DIRS ${LibGpgError_INCLUDE_DIR})
0095 endif()
0096
0097 include(FeatureSummary)
0098 set_package_properties(LibGpgError PROPERTIES
0099 DESCRIPTION "Runtime library for all GnuPG components"
0100 URL https://www.gnupg.org/software/libgpg-error
0101 )