Skip to content

Commit

Permalink
Change ENABLE_AVAHI option to ON/OFF/AUTO
Browse files Browse the repository at this point in the history
  • Loading branch information
zuckschwerdt committed Jan 21, 2024
1 parent 04c4fbb commit e52b129
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
33 changes: 19 additions & 14 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
6 changes: 3 additions & 3 deletions common/FindAvahi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit e52b129

Please sign in to comment.