From 6bd0c63192e7acefbb7538a22aa061912cfc06f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 1 Oct 2023 16:36:32 +0200 Subject: core: make zstd dependency optional (closes #2024) --- src/plugins/relay/CMakeLists.txt | 6 ++++-- src/plugins/relay/weechat/relay-weechat-msg.c | 12 ++++++++++++ src/plugins/relay/weechat/relay-weechat.c | 10 ++++++++-- src/plugins/relay/weechat/relay-weechat.h | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-) (limited to 'src/plugins/relay') diff --git a/src/plugins/relay/CMakeLists.txt b/src/plugins/relay/CMakeLists.txt index dee24c307..953aa7227 100644 --- a/src/plugins/relay/CMakeLists.txt +++ b/src/plugins/relay/CMakeLists.txt @@ -50,8 +50,10 @@ list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS}) list(APPEND LINK_LIBS ${ZLIB_LIBRARY}) -include_directories(${ZSTD_INCLUDE_DIRS}) -list(APPEND LINK_LIBS ${LIBZSTD_LDFLAGS}) +if(ENABLE_ZSTD) + include_directories(${ZSTD_INCLUDE_DIRS}) + list(APPEND LINK_LIBS ${LIBZSTD_LDFLAGS}) +endif() target_link_libraries(relay ${LINK_LIBS} coverage_config) diff --git a/src/plugins/relay/weechat/relay-weechat-msg.c b/src/plugins/relay/weechat/relay-weechat-msg.c index af2bd3d78..aab57d87e 100644 --- a/src/plugins/relay/weechat/relay-weechat-msg.c +++ b/src/plugins/relay/weechat/relay-weechat-msg.c @@ -29,7 +29,9 @@ #include #include #include +#ifdef HAVE_ZSTD #include +#endif #include "../../weechat-plugin.h" #include "../relay.h" @@ -1111,6 +1113,7 @@ int relay_weechat_msg_compress_zstd (struct t_relay_client *client, struct t_relay_weechat_msg *msg) { +#ifdef HAVE_ZSTD char raw_message[1024]; uint32_t size32; Bytef *dest; @@ -1169,6 +1172,13 @@ error: free (dest); return rc; +#else + /* make C compiler happy */ + (void) client; + (void) msg; + + return 0; +#endif /* HAVE_ZSTD */ } /* @@ -1190,10 +1200,12 @@ relay_weechat_msg_send (struct t_relay_client *client, if (relay_weechat_msg_compress_zlib (client, msg)) return; break; +#ifdef HAVE_ZSTD case RELAY_WEECHAT_COMPRESSION_ZSTD: if (relay_weechat_msg_compress_zstd (client, msg)) return; break; +#endif default: break; } diff --git a/src/plugins/relay/weechat/relay-weechat.c b/src/plugins/relay/weechat/relay-weechat.c index c61aacf3a..cfb39922b 100644 --- a/src/plugins/relay/weechat/relay-weechat.c +++ b/src/plugins/relay/weechat/relay-weechat.c @@ -40,8 +40,14 @@ #include "../relay-raw.h" -char *relay_weechat_compression_string[] = /* strings for compression */ -{ "off", "zlib", "zstd" }; +/* strings for compression */ +char *relay_weechat_compression_string[RELAY_WEECHAT_NUM_COMPRESSIONS] = { + "off", + "zlib", +#ifdef HAVE_ZSTD + "zstd", +#endif +}; /* diff --git a/src/plugins/relay/weechat/relay-weechat.h b/src/plugins/relay/weechat/relay-weechat.h index 469536aac..b2b0438b7 100644 --- a/src/plugins/relay/weechat/relay-weechat.h +++ b/src/plugins/relay/weechat/relay-weechat.h @@ -34,7 +34,9 @@ enum t_relay_weechat_compression { RELAY_WEECHAT_COMPRESSION_OFF = 0, /* no compression of binary objects */ RELAY_WEECHAT_COMPRESSION_ZLIB, /* zlib compression */ +#ifdef HAVE_ZSTD RELAY_WEECHAT_COMPRESSION_ZSTD, /* Zstandard compression */ +#endif /* number of compressions */ RELAY_WEECHAT_NUM_COMPRESSIONS, }; -- cgit v1.2.3