summaryrefslogtreecommitdiffstats
path: root/project/cmake/modules/FindAvahi.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'project/cmake/modules/FindAvahi.cmake')
-rw-r--r--project/cmake/modules/FindAvahi.cmake71
1 files changed, 54 insertions, 17 deletions
diff --git a/project/cmake/modules/FindAvahi.cmake b/project/cmake/modules/FindAvahi.cmake
index 24bf15c..77c3e4d 100644
--- a/project/cmake/modules/FindAvahi.cmake
+++ b/project/cmake/modules/FindAvahi.cmake
@@ -1,26 +1,63 @@
1# - Try to find avahi 1#.rst:
2# Once done this will define 2# FindAvahi
3# ---------
4# Finds the avahi library
5#
6# This will will define the following variables::
3# 7#
4# AVAHI_FOUND - system has avahi 8# AVAHI_FOUND - system has avahi
5# AVAHI_INCLUDE_DIRS - the avahi include directory 9# AVAHI_INCLUDE_DIRS - the avahi include directory
6# AVAHI_LIBRARIES - The avahi libraries 10# AVAHI_LIBRARIES - the avahi libraries
11# AVAHI_DEFINITIONS - the avahi definitions
12#
13# and the following imported targets::
14#
15# Avahi::Avahi - The avahi library
7 16
8if(PKG_CONFIG_FOUND) 17if(PKG_CONFIG_FOUND)
9 pkg_check_modules (AVAHI avahi-client) 18 pkg_check_modules(PC_AVAHI avahi-client QUIET)
10 list(APPEND AVAHI_INCLUDE_DIRS ${AVAHI_INCLUDEDIR})
11else()
12 find_path(AVAHI_CLIENT_INCLUDE_DIRS avahi-client/client.h)
13 find_path(AVAHI_COMMON_INCLUDE_DIRS avahi-common/defs.h)
14 find_library(AVAHI_COMMON_LIBRARIES avahi-common)
15 find_library(AVAHI_CLIENT_LIBRARIES avahi-common)
16 set(AVAHI_INCLUDE_DIRS ${AVAHI_CLIENT_INCLUDE_DIRS}
17 ${AVAHI_COMMON_INCLUDE_DIRS})
18 set(AVAHI_LIBRARIES ${AVAHI_CLIENT_LIBRARIES}
19 ${AVAHI_COMMON_LIBRARIES})
20endif() 19endif()
21 20
21find_path(AVAHI_CLIENT_INCLUDE_DIR NAMES avahi-client/client.h
22 PATHS ${PC_AVAHI_INCLUDEDIR})
23find_path(AVAHI_COMMON_INCLUDE_DIR NAMES avahi-common/defs.h
24 PATHS ${PC_AVAHI_INCLUDEDIR})
25find_library(AVAHI_CLIENT_LIBRARY NAMES avahi-client
26 PATHS ${PC_AVAHI_LIBDIR})
27find_library(AVAHI_COMMON_LIBRARY NAMES avahi-common
28 PATHS ${PC_AVAHI_LIBDIR})
29
30set(AVAHI_VERSION ${PC_AVAHI_VERSION})
31
22include(FindPackageHandleStandardArgs) 32include(FindPackageHandleStandardArgs)
23find_package_handle_standard_args(Avahi DEFAULT_MSG AVAHI_INCLUDE_DIRS AVAHI_LIBRARIES) 33find_package_handle_standard_args(Avahi
34 REQUIRED_VARS AVAHI_CLIENT_LIBRARY AVAHI_COMMON_LIBRARY
35 AVAHI_CLIENT_INCLUDE_DIR AVAHI_COMMON_INCLUDE_DIR
36 VERSION_VAR AVAHI_VERSION)
37
38if(AVAHI_FOUND)
39 set(AVAHI_INCLUDE_DIRS ${AVAHI_CLIENT_INCLUDE_DIR}
40 ${AVAHI_COMMON_INCLUDE_DIR})
41 set(AVAHI_LIBRARIES ${AVAHI_CLIENT_LIBRARY}
42 ${AVAHI_COMMON_LIBRARY})
43 set(AVAHI_DEFINITIONS -DHAVE_LIBAVAHI_CLIENT=1 -DHAVE_LIBAVAHI_COMMON=1)
44
45 if(NOT TARGET Avahi::Avahi)
46 add_library(Avahi::Avahi UNKNOWN IMPORTED)
47 set_target_properties(Avahi::Avahi PROPERTIES
48 IMPORTED_LOCATION "${AVAHI_CLIENT_LIBRARY}"
49 INTERFACE_INCLUDE_DIRECTORIES "${AVAHI_CLIENT_INCLUDE_DIR}"
50 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBAVAHI_CLIENT=1)
51 endif()
52 if(NOT TARGET Avahi::AvahiCommon)
53 add_library(Avahi::AvahiCommon UNKNOWN IMPORTED)
54 set_target_properties(Avahi::AvahiCommon PROPERTIES
55 IMPORTED_LOCATION "${AVAHI_COMMON_LIBRARY}"
56 INTERFACE_INCLUDE_DIRECTORIES "${AVAHI_COMMON_INCLUDE_DIR}"
57 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBAVAHI_COMMON=1
58 INTERFACE_LINK_LIBRARIES Avahi::Avahi)
59 endif()
60endif()
24 61
25mark_as_advanced(AVAHI_INCLUDE_DIRS AVAHI_LIBRARIES) 62mark_as_advanced(AVAHI_CLIENT_INCLUDE_DIR AVAHI_COMMON_INCLUDE_DIR
26list(APPEND AVAHI_DEFINITIONS -DHAVE_LIBAVAHI_COMMON=1 -DHAVE_LIBAVAHI_CLIENT=1) 63 AVAHI_CLIENT_LIBRARY AVAHI_COMMON_LIBRARY)