1c87c5fbaSopenharmony_ci# FindTinyDTLS
2c87c5fbaSopenharmony_ci# -----------
3c87c5fbaSopenharmony_ci#
4c87c5fbaSopenharmony_ci# Find the tinyDTLS encryption library.
5c87c5fbaSopenharmony_ci#
6c87c5fbaSopenharmony_ci# Imported Targets
7c87c5fbaSopenharmony_ci# ^^^^^^^^^^^^^^^^
8c87c5fbaSopenharmony_ci#
9c87c5fbaSopenharmony_ci# This module defines the following :prop_tgt:`IMPORTED` targets:
10c87c5fbaSopenharmony_ci#
11c87c5fbaSopenharmony_ci# ``tinydtls``
12c87c5fbaSopenharmony_ci#   The tinyDTLS ``tinydtls`` library, if found.
13c87c5fbaSopenharmony_ci#
14c87c5fbaSopenharmony_ci# Result Variables
15c87c5fbaSopenharmony_ci# ^^^^^^^^^^^^^^^^
16c87c5fbaSopenharmony_ci#
17c87c5fbaSopenharmony_ci# This module will set the following variables in your project:
18c87c5fbaSopenharmony_ci#
19c87c5fbaSopenharmony_ci# ``TINYDTLS_FOUND``
20c87c5fbaSopenharmony_ci#   System has the tinyDTLS library.
21c87c5fbaSopenharmony_ci# ``TINYDTLS_INCLUDE_DIR``
22c87c5fbaSopenharmony_ci#   The tinyDTLS include directory.
23c87c5fbaSopenharmony_ci# ``TINYDTLS_LIBRARIES``
24c87c5fbaSopenharmony_ci#   All tinyDTLS libraries.
25c87c5fbaSopenharmony_ci#
26c87c5fbaSopenharmony_ci# Hints
27c87c5fbaSopenharmony_ci# ^^^^^
28c87c5fbaSopenharmony_ci#
29c87c5fbaSopenharmony_ci# Set ``TINYDTLS_ROOT_DIR`` to the root directory of an tinyDTLS installation.
30c87c5fbaSopenharmony_ci
31c87c5fbaSopenharmony_ciif(TINYDTLS_ROOT_DIR)
32c87c5fbaSopenharmony_ci  set(_EXTRA_FIND_ARGS "NO_CMAKE_FIND_ROOT_PATH")
33c87c5fbaSopenharmony_ciendif()
34c87c5fbaSopenharmony_ci
35c87c5fbaSopenharmony_cifind_path(
36c87c5fbaSopenharmony_ci  TINYDTLS_INCLUDE_DIR
37c87c5fbaSopenharmony_ci  NAMES tinydtls/dtls.h
38c87c5fbaSopenharmony_ci  PATH_SUFFIXES include
39c87c5fbaSopenharmony_ci  HINTS ${PROJECT_SOURCE_DIR}
40c87c5fbaSopenharmony_ci        ${CMAKE_CURRENT_BINARY_DIR}
41c87c5fbaSopenharmony_ci        ${TINYDTLS_ROOT_DIR}
42c87c5fbaSopenharmony_ci        ${_EXTRA_FIND_ARGS})
43c87c5fbaSopenharmony_ci
44c87c5fbaSopenharmony_cifind_library(
45c87c5fbaSopenharmony_ci  TINYDTLS_LIBRARIES
46c87c5fbaSopenharmony_ci  NAMES tinydtls
47c87c5fbaSopenharmony_ci  PATH_SUFFIXES lib
48c87c5fbaSopenharmony_ci  HINTS ${PROJECT_SOURCE_DIR}
49c87c5fbaSopenharmony_ci        ${CMAKE_CURRENT_BINARY_DIR}
50c87c5fbaSopenharmony_ci        ${TINYDTLS_ROOT_DIR}
51c87c5fbaSopenharmony_ci        ${_EXTRA_FIND_ARGS})
52c87c5fbaSopenharmony_ci
53c87c5fbaSopenharmony_ciif(TINYDTLS_LIBRARIES)
54c87c5fbaSopenharmony_ci  set(TINYDTLS_FOUND TRUE)
55c87c5fbaSopenharmony_cielse()
56c87c5fbaSopenharmony_ci  set(TINYDTLS_FOUND FALSE)
57c87c5fbaSopenharmony_ci  if(TinyDTLS_FIND_REQUIRED)
58c87c5fbaSopenharmony_ci    message(FATAL_ERROR "Tinydtls could not be found")
59c87c5fbaSopenharmony_ci  endif()
60c87c5fbaSopenharmony_ciendif()
61c87c5fbaSopenharmony_ci
62c87c5fbaSopenharmony_ciinclude(FindPackageHandleStandardArgs)
63c87c5fbaSopenharmony_cifind_package_handle_standard_args(
64c87c5fbaSopenharmony_ci  tinyDTLS
65c87c5fbaSopenharmony_ci  FOUND_VAR
66c87c5fbaSopenharmony_ci  TINYDTLS_FOUND
67c87c5fbaSopenharmony_ci  REQUIRED_VARS
68c87c5fbaSopenharmony_ci  TINYDTLS_INCLUDE_DIR
69c87c5fbaSopenharmony_ci  TINYDTLS_LIBRARIES
70c87c5fbaSopenharmony_ci  VERSION_VAR)
71c87c5fbaSopenharmony_ci
72c87c5fbaSopenharmony_ciif(NOT
73c87c5fbaSopenharmony_ci   TARGET
74c87c5fbaSopenharmony_ci   tinydtls)
75c87c5fbaSopenharmony_ci  add_library(
76c87c5fbaSopenharmony_ci    tinydtls
77c87c5fbaSopenharmony_ci    UNKNOWN
78c87c5fbaSopenharmony_ci    IMPORTED)
79c87c5fbaSopenharmony_ci  set_target_properties(
80c87c5fbaSopenharmony_ci    tinydtls
81c87c5fbaSopenharmony_ci    PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${TINYDTLS_INCLUDE_DIR}"
82c87c5fbaSopenharmony_ci               IMPORTED_LINK_INTERFACE_LANGUAGES "C"
83c87c5fbaSopenharmony_ci               IMPORTED_LOCATION "${TINYDTLS_LIBRARIES}")
84c87c5fbaSopenharmony_ciendif()
85c87c5fbaSopenharmony_ci
86c87c5fbaSopenharmony_cimessage(STATUS "TINYDTLS_INCLUDE_DIR: ${TINYDTLS_INCLUDE_DIR}")
87c87c5fbaSopenharmony_cimessage(STATUS "TINYDTLS_LIBRARIES: ${TINYDTLS_LIBRARIES}")
88c87c5fbaSopenharmony_cimessage(STATUS "TINYDTLS_ROOT_DIR: ${TINYDTLS_ROOT_DIR}")
89