File: FindLibidn2.cmake

package info (click to toggle)
getdns 1.7.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,752 kB
  • sloc: ansic: 57,351; sh: 407; xml: 38; makefile: 22
file content (69 lines) | stat: -rw-r--r-- 1,900 bytes parent folder | download | duplicates (3)
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
#[=======================================================================[.rst:
FindLibidn2
-----------

Find the Libidn2 library

Imported targets
^^^^^^^^^^^^^^^^

This module defines the following :prop_tgt:`IMPORTED` targets:

``Libidn2::Libidn2``
  The Libidn2 library, if found.

Result variables
^^^^^^^^^^^^^^^^

This module will set the following variables in your project:

``Libidn2_FOUND``
  If false, do not try to use Libidn2.
``LIBIDN2_INCLUDE_DIR``
  where to find libidn2 headers.
``LIBIDN2_LIBRARIES``
  the libraries needed to use Libidn2.
``LIBIDN2_VERSION``
  the version of the Libidn2 library found

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

find_path(LIBIDN2_INCLUDE_DIR idn2.h
  HINTS
  "${LIBIDN2_DIR}"
  "${LIBIDN2_DIR}/include"
)

find_library(LIBIDN2_LIBRARY NAMES idn2 libidn2
  HINTS
  "${LIBIDN2_DIR}"
  "${LIBIDN2_DIR}/lib"
)

set(LIBIDN2_LIBRARIES "")

if (LIBIDN2_INCLUDE_DIR AND LIBIDN2_LIBRARY)
  if (NOT TARGET Libidn2::Libidn2)
    add_library(Libidn2::Libidn2 UNKNOWN IMPORTED)
    set_target_properties(Libidn2::Libidn2 PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${LIBIDN2_INCLUDE_DIR}"
      IMPORTED_LINK_INTERFACE_LANGUAGES "C"
      IMPORTED_LOCATION "${LIBIDN2_LIBRARY}"
      )
  endif ()

  if (NOT LIBIDN2_VERSION AND LIBIDN2_INCLUDE_DIR AND EXISTS "${LIBIDN2_INCLUDE_DIR}/idn2.h")
    file(STRINGS "${LIBIDN2_INCLUDE_DIR}/idn2.h" LIBIDN2_H REGEX "^[ \t]*#[ \t]*define[ \t]+IDN2_VERSION[ \t]")
    string(REGEX REPLACE "^.*IDN2_VERSION[ \t]+\"([0-9.]+)\".*$" "\\1" LIBIDN2_VERSION "${LIBIDN2_H}")
  endif ()
endif()

list(APPEND LIBIDN2_LIBRARIES "${LIBIDN2_LIBRARY}")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libidn2
  REQUIRED_VARS LIBIDN2_LIBRARIES LIBIDN2_INCLUDE_DIR
  VERSION_VAR LIBIDN2_VERSION
  )

mark_as_advanced(LIBIDN2_INCLUDE_DIR LIBIDN2_LIBRARIES LIBIDN2_LIBRARY)