From 1b2668f562e955c3a560e63377dfef3a211ae140 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Sun, 22 May 2022 16:03:03 +0100 Subject: [PATCH] CMakeLists.txt: Correctly determine cmsghdr support for determining addresses check_symbol_exists() only works for defines etc., not struct, so look for CMSG_FIRSTHDR instead. Make sure _GNU_SOURCE is defined to pick up the in6_pktinfo definition needed for the logic using cmsghdr. --- CMakeLists.txt | 2 +- cmake_coap_config.h.in | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd3f2d95..86535cf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,7 +167,7 @@ if(WIN32) set(HAVE_STRUCT_CMSGHDR 1) else() check_symbol_exists( - cmsghdr + CMSG_FIRSTHDR sys/socket.h HAVE_STRUCT_CMSGHDR) endif() diff --git a/cmake_coap_config.h.in b/cmake_coap_config.h.in index 12444227..d01ab53d 100644 --- a/cmake_coap_config.h.in +++ b/cmake_coap_config.h.in @@ -13,6 +13,10 @@ #ifndef COAP_CONFIG_H_ #define COAP_CONFIG_H_ +#if ! defined(_WIN32) +#define _GNU_SOURCE +#endif + /* Define to 1 if you have header file. */ #cmakedefine HAVE_WS2TCPIP_H @HAVE_WS2TCPIP_H@