Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds option ENABLE_AVAHI #97

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,36 @@ endif (WIN32)

#avahi for discovery over mDNS/DNS-SD daemon
if (UNIX AND NOT APPLE)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Avahi)
if (NOT AVAHI_FOUND)
message(WARNING
"Cannot find Avahi client development files:"
"Avahi is recommended for device discovery over mDNS."
"Please install libavahi-client-dev or equivalent.")
endif ()
endif ()
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(Avahi_FOUND)
message(STATUS "Avahi discovery support will be compiled.")
elseif(ENABLE_AVAHI STREQUAL "AUTO")
message(WARNING
"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()
message(STATUS "Avahi discovery support disabled.")
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...")
target_sources(SoapySDRRemoteCommon PRIVATE SoapyMDNSEndpointNone.cpp)
endif ()

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()
Loading