mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-02-06 11:12:09 +08:00
Add compile time checks for whether -lanl is required
Prior to glibc 2.34 this was required
This commit is contained in:
@@ -23,6 +23,8 @@ if(APPLE)
|
||||
endif(APPLE)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePushCheckState)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
option(WITH_BUNDLED_DEPS "Build with bundled dependencies?" ON)
|
||||
option(WITH_TLS
|
||||
|
||||
@@ -318,7 +318,10 @@ ifeq ($(WITH_EC),yes)
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_ADNS),yes)
|
||||
BROKER_LDADD:=$(BROKER_LDADD) -lanl
|
||||
NEED_LIBANL:=$(shell printf 'int main(){return 0;}' | gcc -D_GNU_SOURCE -lanl -o /dev/null -x c - 2>/dev/null || echo yes)
|
||||
ifeq ($(NEED_LIBANL),yes)
|
||||
BROKER_LDADD+=-lanl
|
||||
endif
|
||||
BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_ADNS
|
||||
endif
|
||||
|
||||
|
||||
@@ -165,12 +165,31 @@ endif (WITH_DLT)
|
||||
|
||||
set (MOSQ_LIBS ${MOSQ_LIBS} OpenSSL::SSL)
|
||||
# Check for getaddrinfo_a
|
||||
include(CheckLibraryExists)
|
||||
check_library_exists(anl getaddrinfo_a "" HAVE_GETADDRINFO_A)
|
||||
if (HAVE_GETADDRINFO_A AND WITH_ADNS)
|
||||
add_definitions("-DWITH_ADNS")
|
||||
add_definitions(-DHAVE_GETADDRINFO_A)
|
||||
set (MOSQ_LIBS ${MOSQ_LIBS} anl)
|
||||
# Prior to glibc 2.34 this required linking with anl
|
||||
if(WITH_ADNS)
|
||||
cmake_push_check_state()
|
||||
set(ANL_CODE "
|
||||
#include <stdlib.h>
|
||||
#include <netdb.h>
|
||||
int main(){
|
||||
return getaddrinfo_a(0, NULL, 0, NULL);
|
||||
}
|
||||
")
|
||||
check_source_compiles(C "${ANL_CODE}" HAVE_GETADDRINFO_A)
|
||||
if(HAVE_GETADDRINFO_A)
|
||||
add_definitions(mosquitto PRIVATE "WITH_ADNS")
|
||||
else()
|
||||
set(CMAKE_REQUIRED_LIBRARIES "anl")
|
||||
check_source_compiles(C "${ANL_CODE}" HAVE_GETADDRINFO_A_LIBANL)
|
||||
|
||||
if(HAVE_GETADDRINFO_A_LIBANL)
|
||||
add_definitions(mosquitto PRIVATE "WITH_ADNS")
|
||||
set (MOSQ_LIBS ${MOSQ_LIBS} anl)
|
||||
else()
|
||||
message(FATAL_ERROR "WITH_ADNS is set, but getaddrinfo_a() is not available.")
|
||||
endif()
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
endif (HAVE_GETADDRINFO_A AND WITH_ADNS)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user