Skip to content

Commit

Permalink
build: use the system provided c-ares if found
Browse files Browse the repository at this point in the history
e.g. buildroot has logic to build c-ares,
so if pkg_check_modules can find a suitable version,
then use that one if -DFLB_PREFER_SYSTEM_LIBS=Yes.

Note that the CheckIncludeFiles include for wasm is added,
since that was done by c-ares otherwise.

Signed-off-by: Thomas Devoogdt <[email protected]>
  • Loading branch information
ThomasDevoogdt committed Jun 10, 2024
1 parent 7f6714a commit 95ccc2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -581,16 +581,27 @@ else()
endif()

# C-Ares (DNS library)
FLB_OPTION(CARES_STATIC ON)
FLB_OPTION(CARES_SHARED OFF)
FLB_OPTION(CARES_INSTALL OFF)
FLB_OPTION(CARES_BUILD_TESTS OFF)
FLB_OPTION(CARES_BUILD_TOOLS OFF)
if (FLB_SYSTEM_MACOS)
# macOS SDK always has <arpa/nameser.h>.
FLB_DEFINITION(CARES_HAVE_ARPA_NAMESER_H)
if(FLB_PREFER_SYSTEM_LIBS)
find_package(PkgConfig)
pkg_check_modules(CARES libcares>=1.0.0)
endif()
if(CARES_FOUND)
include_directories(${CARES_INCLUDE_DIRS})
link_directories(${CARES_LIBRARY_DIRS})
else()
FLB_OPTION(CARES_STATIC ON)
FLB_OPTION(CARES_SHARED OFF)
FLB_OPTION(CARES_INSTALL OFF)
FLB_OPTION(CARES_BUILD_TESTS OFF)
FLB_OPTION(CARES_BUILD_TOOLS OFF)
if (FLB_SYSTEM_MACOS)
# macOS SDK always has <arpa/nameser.h>.
FLB_DEFINITION(CARES_HAVE_ARPA_NAMESER_H)
endif()
add_subdirectory(${FLB_PATH_LIB_CARES})# EXCLUDE_FROM_ALL)

set(CARES_LIBRARIES "c-ares")
endif()
add_subdirectory(${FLB_PATH_LIB_CARES})# EXCLUDE_FROM_ALL)

# Chunk I/O
FLB_OPTION(CIO_LIB_STATIC ON)
Expand Down Expand Up @@ -660,6 +671,7 @@ if(FLB_WASM)
_Atomic int a;
return 0;
}" FLB_HAVE_STDATOMIC_H)
include(CheckIncludeFiles)
check_include_files(stdatomic.h FLB_HAVE_STDATOMIC_H)
if (FLB_HAVE_STDATOMIC_H)
enable_language (ASM)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ set(FLB_DEPS
${FLB_PLUGINS}
${FLB_PROXY_PLUGINS}
${extra_libs}
c-ares
${CARES_LIBRARIES}
snappy-c
lwrb
${NGHTTP2_LIBRARIES}
Expand Down

0 comments on commit 95ccc2d

Please sign in to comment.