dont look for dns_sd.h if avahi is absent and mdnsd is present

This commit is contained in:
fduncanh
2021-11-23 04:06:20 -05:00
parent ac2d6e88df
commit 72aab72e0c

View File

@@ -74,29 +74,19 @@ elseif( APPLE )
)
endif()
#dns_sd (we only need to find the dns_sd.h include file for non_Apple systems)
#dns_sd
if ( UNIX AND NOT APPLE )
pkg_check_modules(AVAHI_COMPAT avahi-compat-libdns_sd)
if( AVAHI_COMPAT_FOUND )
message( STATUS "AVAHI_COMPAT_INCLUDE_DIRS " ${AVAHI_COMPAT_INCLUDE_DIRS} )
target_include_directories( airplay PUBLIC ${AVAHI_COMPAT_INCLUDE_DIRS} )
message( STATUS "AVAHI_COMPAT_LIBRARIES " ${AVAHI_COMPAT_LIBRARIES} )
target_link_libraries( airplay ${AVAHI_COMPAT_LIBRARIES} )
else() # dns_sd can be provided by mdnsResponder instead of Avahi.
find_library(DNS_SD dns_sd )
if( NOT DNS_SD )
message( FATAL_ERROR "libdns_sd not found; suggestion: install avahi-compat-libdns-sd ")
else()
message( STATUS "libdns_sd found at " ${DNS_SD} )
endif()
set ( INCLUDE_PATHS " /usr/include/ /usr/include/* /usr/local/include/ /usr/local/include/* " )
find_file( DNS_SD_H dns_sd.h PATHS ${INCLUDE_PATHS} )
if( NOT DNS_SD_H )
message( FATAL_ERROR " dns_sd.h not found in PATHS " ${INCLUDE_PATHS})
endif()
string( REPLACE "dns_sd.h" "" DNSSD_INCLUDE_DIR ${DNS_SD_H} )
message( STATUS "found dns_sd.h in " ${DNSSD_INCLUDE_DIR} )
target_include_directories( airplay PRIVATE ${DNSSD_INCLUDE_DIR} )
target_link_libraries( airplay dns_sd )
pkg_check_modules(AVAHI_DNSSD avahi-compat-libdns_sd)
if (AVAHI_DNSSD_FOUND)
target_include_directories( airplay PUBLIC ${AVAHI_DNSSD_INCLUDE_DIRS} )
target_link_libraries( airplay ${AVAHI_DNSSD_LIBRARIES} )
else() # this might still work if mdnsd (mDNSResponder) is present instead of avahi
find_library( DNS_SD dns_sd )
if( NOT DNS_SD )
message( FATAL_ERROR "libdns_sd not found: install avahi_compat-libdns_sd" )
else()
target_link_libraries(airplay dns_sd )
endif()
endif()
endif()