summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindMDNS.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindMDNS.cmake')
-rw-r--r--cmake/modules/FindMDNS.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmake/modules/FindMDNS.cmake b/cmake/modules/FindMDNS.cmake
new file mode 100644
index 0000000..c001f7b
--- /dev/null
+++ b/cmake/modules/FindMDNS.cmake
@@ -0,0 +1,47 @@
1#.rst:
2# FindMDNS
3# --------
4# Finds the mDNS library
5#
6# This will will define the following variables::
7#
8# MDNS_FOUND - system has mDNS
9# MDNS_INCLUDE_DIRS - the mDNS include directory
10# MDNS_LIBRARIES - the mDNS libraries
11# MDNS_DEFINITIONS - the mDNS definitions
12#
13# and the following imported targets::
14#
15# MDNS::MDNS - The mDNSlibrary
16
17find_path(MDNS_INCLUDE_DIR NAMES dmDnsEmbedded.h dns_sd.h)
18find_library(MDNS_LIBRARY NAMES mDNSEmbedded dnssd)
19
20find_path(MDNS_EMBEDDED_INCLUDE_DIR NAMES mDnsEmbedded.h)
21
22include(FindPackageHandleStandardArgs)
23find_package_handle_standard_args(MDNS
24 REQUIRED_VARS MDNS_LIBRARY MDNS_INCLUDE_DIR)
25
26if(MDNS_FOUND)
27 set(MDNS_INCLUDE_DIRS ${MDNS_INCLUDE_DIR})
28 set(MDNS_LIBRARIES ${MDNS_LIBRARY})
29 set(MDNS_DEFINITIONS -DHAVE_LIBMDNS=1)
30 if(MDNS_EMBEDDED_INCLUDE_DIR)
31 list(APPEND MDNS_DEFINITIONS -DHAVE_LIBMDNSEMBEDDED=1)
32 endif()
33
34 if(NOT TARGET MDNS::MDNS)
35 add_library(MDNS::MDNS UNKNOWN IMPORTED)
36 set_target_properties(MDNS::MDNS PROPERTIES
37 IMPORTED_LOCATION "${MDNS_LIBRARY}"
38 INTERFACE_INCLUDE_DIRECTORIES "${MDNS_INCLUDE_DIR}"
39 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBMDNS=1)
40 if(MDNS_EMBEDDED_INCLUDE_DIR)
41 set_target_properties(MDNS::MDNS PROPERTIES
42 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBMDNSEMBEDDED=1)
43 endif()
44 endif()
45endif()
46
47mark_as_advanced(MDNS_INCLUDE_DIR MDNS_EMBEDDED_INCLUDE_DIR MDNS_LIBRARY)