mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpinet] Add option to use directly linked Avahi from cmake (#8469)
This commit is contained in:
@@ -128,6 +128,21 @@ target_compile_features(wpinet PUBLIC cxx_std_20)
|
||||
wpilib_target_warnings(wpinet)
|
||||
target_link_libraries(wpinet PUBLIC wpiutil)
|
||||
|
||||
if(USE_LINKED_AVAHI)
|
||||
find_library(AVAHI_COMMON REQUIRED NAMES avahi-common)
|
||||
if(AVAHI_COMMON)
|
||||
message(STATUS "Found avahi common: ${AVAHI_COMMON}")
|
||||
endif()
|
||||
|
||||
find_library(AVAHI_CLIENT REQUIRED NAMES avahi-client)
|
||||
if(AVAHI_CLIENT)
|
||||
message(STATUS "Found avahi client: ${AVAHI_CLIENT}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(wpinet PUBLIC ${AVAHI_COMMON} ${AVAHI_CLIENT})
|
||||
target_compile_definitions(wpinet PRIVATE DIRECT_LINK_AVAHI)
|
||||
endif()
|
||||
|
||||
if(NOT USE_SYSTEM_LIBUV)
|
||||
target_sources(wpinet PRIVATE ${uv_native_src})
|
||||
install(
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
using namespace wpi::net;
|
||||
|
||||
#ifdef DIRECT_LINK_AVAHI
|
||||
#define AvahiFunctionLoad(snake_name) snake_name = &::avahi_##snake_name
|
||||
#else
|
||||
#define AvahiFunctionLoad(snake_name) \
|
||||
do { \
|
||||
snake_name = \
|
||||
@@ -19,6 +22,7 @@ using namespace wpi::net;
|
||||
return; \
|
||||
} \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
AvahiFunctionTable::AvahiFunctionTable() {
|
||||
void* lib = dlopen("libavahi-common.so.3", RTLD_LAZY);
|
||||
|
||||
@@ -8,6 +8,20 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#ifdef DIRECT_LINK_AVAHI
|
||||
#include "avahi-client/client.h"
|
||||
#include "avahi-client/lookup.h"
|
||||
#include "avahi-client/publish.h"
|
||||
#include "avahi-common/address.h"
|
||||
#include "avahi-common/alternative.h"
|
||||
#include "avahi-common/domain.h"
|
||||
#include "avahi-common/error.h"
|
||||
#include "avahi-common/malloc.h"
|
||||
#include "avahi-common/strlst.h"
|
||||
#include "avahi-common/thread-watch.h"
|
||||
|
||||
#else
|
||||
|
||||
/***
|
||||
This file is part of avahi.
|
||||
avahi is free software; you can redistribute it and/or modify it
|
||||
@@ -24,6 +38,8 @@
|
||||
USA.
|
||||
***/
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef struct AvahiPoll AvahiPoll;
|
||||
|
||||
typedef enum {
|
||||
@@ -223,6 +239,10 @@ enum {
|
||||
AVAHI_ERR_MAX = -54
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif
|
||||
|
||||
namespace wpi::net {
|
||||
class AvahiFunctionTable {
|
||||
public:
|
||||
@@ -235,8 +255,8 @@ class AvahiFunctionTable {
|
||||
AvahiFunction(threaded_poll_get, const AvahiPoll*, (AvahiThreadedPoll*));
|
||||
AvahiFunction(threaded_poll_start, int, (AvahiThreadedPoll*));
|
||||
AvahiFunction(threaded_poll_stop, int, (AvahiThreadedPoll*));
|
||||
AvahiFunction(threaded_poll_lock, int, (AvahiThreadedPoll*));
|
||||
AvahiFunction(threaded_poll_unlock, int, (AvahiThreadedPoll*));
|
||||
AvahiFunction(threaded_poll_lock, void, (AvahiThreadedPoll*));
|
||||
AvahiFunction(threaded_poll_unlock, void, (AvahiThreadedPoll*));
|
||||
|
||||
AvahiFunction(client_new, AvahiClient*,
|
||||
(const AvahiPoll* poll_api, AvahiClientFlags flags,
|
||||
|
||||
Reference in New Issue
Block a user