File: FindLibGpgError.cmake

package info (click to toggle)
libkleo 4%3A24.12.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,240 kB
  • sloc: cpp: 30,756; ansic: 302; makefile: 16; sh: 3
file content (101 lines) | stat: -rw-r--r-- 3,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# SPDX-FileCopyrightText: 2022 g10 Code GmbH
# SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
#
# SPDX-License-Identifier: BSD-3-Clause

#[=======================================================================[.rst:
FindLibGpgError
---------------

Try to find the Libgpg-error library.

This will define the following variables:

``LibGpgError_FOUND``
    True if (the requested version of) Libgpg-error was found
``LibGpgError_VERSION``
    The version of the Libgpg-error library which was found
``LibGpgError_LIBRARIES``
    Libraries you need to link when using Libgpg-error This can be passed to
    target_link_libraries() instead of the ``LibGpgError::LibGpgError`` target.
``LibGpgError_INCLUDE_DIRS``
    Include directories needed to use Libgpg-error This should be passed to
    target_include_directories() if the target is not used for linking.
``LibGpgError_DEFINITIONS``
    Compile definitions to use when compiling code that uses Libgpg-error
    This should be passed to target_compile_options() if the target is not
    used for linking.

If ``LibGpgError_FOUND`` is TRUE, it will also define the following imported target:

``LibGpgError::LibGpgError``
    The Libgpg-error library

#]=======================================================================]

find_package(PkgConfig QUIET)
pkg_check_modules(PC_LibGpgError QUIET gpg-error)

set(LibGpgError_VERSION ${PC_LibGpgError_VERSION})
set(LibGpgError_DEFINITIONS ${PC_LibGpgError_CFLAGS_OTHER})

find_path(LibGpgError_INCLUDE_DIR
    NAMES
        gpg-error.h
    PATHS
        ${PC_LibGpgError_INCLUDE_DIRS}
)
find_library(LibGpgError_LIBRARY
    NAMES
        gpg-error
    PATHS
        ${PC_LibGpgError_LIBRARY_DIRS}
)

if(LibGpgError_INCLUDE_DIR AND NOT LibGpgError_VERSION)
    # The version is given in the format MAJOR.MINOR optionally followed
    # by an intermediate "beta" version given as -betaNUM, e.g. "1.47-beta7".
    file(STRINGS "${LibGpgError_INCLUDE_DIR}/gpg-error.h" LibGpgError_VERSION_STR
         REGEX "^#[\t ]*define[\t ]+GPG_ERROR_VERSION[\t ]+\"([0-9])+\\.([0-9])+(-[a-z0-9]*)?\".*")
    string(REGEX REPLACE "^.*GPG_ERROR_VERSION[\t ]+\"([0-9]+\\.[0-9]+(-[a-z0-9]*)?)\".*$"
           "\\1" LibGpgError_VERSION_STR "${LibGpgError_VERSION_STR}")

    set(LibGpgError_VERSION "${LibGpgError_VERSION_STR}")

    unset(LibGpgError_VERSION_STR)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibGpgError
    REQUIRED_VARS
        LibGpgError_LIBRARY
        LibGpgError_INCLUDE_DIR
        LibGpgError_VERSION
    VERSION_VAR
        LibGpgError_VERSION
)

if(LibGpgError_FOUND AND NOT TARGET LibGpgError::LibGpgError)
    add_library(LibGpgError::LibGpgError UNKNOWN IMPORTED)
    set_target_properties(LibGpgError::LibGpgError PROPERTIES
        IMPORTED_LOCATION "${LibGpgError_LIBRARY}"
        INTERFACE_COMPILE_OPTIONS "${LibGpgError_DEFINITIONS}"
        INTERFACE_INCLUDE_DIRECTORIES "${LibGpgError_INCLUDE_DIR}"
    )
endif()

mark_as_advanced(
    LibGpgError_INCLUDE_DIR
    LibGpgError_LIBRARY
)

if(LibGpgError_FOUND)
    set(LibGpgError_LIBRARIES ${LibGpgError_LIBRARY})
    set(LibGpgError_INCLUDE_DIRS ${LibGpgError_INCLUDE_DIR})
endif()

include(FeatureSummary)
set_package_properties(LibGpgError PROPERTIES
    DESCRIPTION "Runtime library for all GnuPG components"
    URL https://www.gnupg.org/software/libgpg-error
)