diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index bea8fbc..41dba59 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -62,28 +62,33 @@ endif (WIN32) #avahi for discovery over mDNS/DNS-SD daemon if (UNIX AND NOT APPLE) - option(ENABLE_AVAHI "enable support for avahi discovery" ON) - if (ENABLE_AVAHI) + set(ENABLE_AVAHI AUTO CACHE STRING "Enable support for Avahi discovery") + set_property(CACHE ENABLE_AVAHI PROPERTY STRINGS AUTO ON OFF) + if(ENABLE_AVAHI) # AUTO / ON list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) find_package(Avahi) - if (NOT AVAHI_FOUND) + if(Avahi_FOUND) + message(STATUS "Avahi discovery support will be compiled.") + elseif(ENABLE_AVAHI STREQUAL "AUTO") message(WARNING - "Cannot find Avahi client development files:" - "Avahi is recommended for device discovery over mDNS." - "Please install libavahi-client-dev or equivalent.") - endif () + "Could NOT find Avahi client development files: " + "Avahi is recommended for device discovery over mDNS. " + "Consider installing libavahi-client-dev or equivalent.") + else() + message(FATAL_ERROR "Avahi client for discovery support not found.") + endif() else() - set(AVAHI_FOUND FALSE) + message(STATUS "Avahi discovery support disabled.") endif() -endif () +endif() if (APPLE) target_sources(SoapySDRRemoteCommon PRIVATE SoapyMDNSEndpointApple.cpp) -elseif (AVAHI_FOUND) - message(STATUS "AVAHI_INCLUDE_DIRS=${AVAHI_INCLUDE_DIRS}") - message(STATUS "AVAHI_LIBRARIES=${AVAHI_LIBRARIES}") - target_include_directories(SoapySDRRemoteCommon PRIVATE ${AVAHI_INCLUDE_DIRS}) - target_link_libraries(SoapySDRRemoteCommon PRIVATE ${AVAHI_LIBRARIES}) +elseif (Avahi_FOUND) + message(STATUS "Avahi_INCLUDE_DIRS=${Avahi_INCLUDE_DIRS}") + message(STATUS "Avahi_LIBRARIES=${Avahi_LIBRARIES}") + target_include_directories(SoapySDRRemoteCommon PRIVATE ${Avahi_INCLUDE_DIRS}) + target_link_libraries(SoapySDRRemoteCommon PRIVATE ${Avahi_LIBRARIES}) target_sources(SoapySDRRemoteCommon PRIVATE SoapyMDNSEndpointAvahi.cpp) else () message(STATUS "No mDNS support configured...") diff --git a/common/FindAvahi.cmake b/common/FindAvahi.cmake index bc4d5f2..f119e4e 100644 --- a/common/FindAvahi.cmake +++ b/common/FindAvahi.cmake @@ -3,7 +3,7 @@ find_library(AVAHI_LIBRARY-CLIENT NAMES avahi-client) find_path(AVAHI_INCLUDE_DIR avahi-client/publish.h) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Avahi DEFAULT_MSG AVAHI_LIBRARY-COMMON AVAHI_LIBRARY-CLIENT AVAHI_INCLUDE_DIR) -if(AVAHI_FOUND) - set(AVAHI_LIBRARIES ${AVAHI_LIBRARY-COMMON} ${AVAHI_LIBRARY-CLIENT}) - set(AVAHI_INCLUDE_DIRS ${AVAHI_INCLUDE_DIR}) +if(Avahi_FOUND) + set(Avahi_LIBRARIES ${AVAHI_LIBRARY-COMMON} ${AVAHI_LIBRARY-CLIENT}) + set(Avahi_INCLUDE_DIRS ${AVAHI_INCLUDE_DIR}) endif()