Using pkg-config helps to find libraries on systems where these libraries are installed in non-standard locations.
55 lines
1.4 KiB
CMake
55 lines
1.4 KiB
CMake
# Try to find the Avahi libraries and headers
|
|
# Once done this will define:
|
|
#
|
|
# AVAHI_FOUND - system has the avahi libraries
|
|
# AVAHI_INCLUDE_DIRS - the avahi include directories
|
|
# AVAHI_LIBRARIES - The libraries needed to use avahi
|
|
|
|
# use pkg-config to get the directories and then use these values
|
|
# in the find_path() and find_library() calls
|
|
find_package(PkgConfig)
|
|
|
|
if(PKG_CONFIG_FOUND)
|
|
pkg_check_modules(_AVAHI avahi-client)
|
|
endif(PKG_CONFIG_FOUND)
|
|
|
|
find_library(AVAHI_COMMON_LIB NAMES avahi-common
|
|
PATHS
|
|
${_AVAHI_LIBRARY_DIRS}
|
|
${COMMON_LIB_DIR}
|
|
)
|
|
|
|
find_library(AVAHI_CLIENT_LIB NAMES avahi-client
|
|
PATHS
|
|
${_AVAHI_LIBRARY_DIRS}
|
|
${CLIENT_LIB_DIR}
|
|
)
|
|
|
|
if(AVAHI_COMMON_LIB AND AVAHI_CLIENT_LIB)
|
|
set(AVAHI_LIBRARIES ${AVAHI_COMMON_LIB} ${AVAHI_CLIENT_LIB})
|
|
message(STATUS "Avahi-Libs found: ${AVAHI_LIBRARIES}")
|
|
endif()
|
|
|
|
find_path(COMMON_INCLUDE_DIR watch.h
|
|
PATH_SUFFIXES avahi-common
|
|
PATHS
|
|
${_AVAHI_INCLUDE_DIRS}
|
|
${COMMON_INCLUDE_DIR}
|
|
)
|
|
|
|
find_path(CLIENT_INCLUDE_DIR client.h
|
|
PATH_SUFFIXES avahi-client
|
|
PATHS
|
|
${_AVAHI_INCLUDE_DIRS}
|
|
${CLIENT_INCLUDE_DIR}
|
|
)
|
|
|
|
if(COMMON_INCLUDE_DIR AND CLIENT_INCLUDE_DIR)
|
|
set(AVAHI_INCLUDE_DIRS ${COMMON_INCLUDE_DIR} ${CLIENT_INCLUDE_DIR})
|
|
message(STATUS "Avahi-Include-Dirs found: ${AVAHI_INCLUDE_DIRS}")
|
|
endif()
|
|
|
|
if(AVAHI_LIBRARIES AND AVAHI_INCLUDE_DIRS)
|
|
set(AVAHI_FOUND TRUE)
|
|
endif()
|