diff --git a/CMakeLists.txt b/CMakeLists.txt index 75a05b0c7..571c961d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,7 @@ include(FindPkgConfig) include(CheckIncludeFiles) include(CheckFunctionExists) include(CheckSymbolExists) +include(CheckLibraryExists) check_include_files("langinfo.h" HAVE_LANGINFO_CODESET) check_include_files("sys/resource.h" HAVE_SYS_RESOURCE_H) @@ -222,6 +223,16 @@ check_symbol_exists("htonll" "sys/types.h;netinet/in.h;inttypes.h" HAVE_HTONLL) check_symbol_exists("eat_newline_glitch" "term.h" HAVE_EAT_NEWLINE_GLITCH) +# Check if res_init requires libresolv +check_function_exists(res_init, LIBC_HAS_RES_INIT) +if(NOT LIBC_HAS_RES_INIT) + find_library(RESOLV_LIBRARY resolv) + check_library_exists("${RESOLV_LIBRARY}" res_init "" LIBRESOLV_HAS_RES_INIT) + if(LIBRESOLV_HAS_RES_INIT) + list(APPEND EXTRA_LIBS ${RESOLV_LIBRARY}) + endif() +endif() + # Check for Large File Support if(ENABLE_LARGEFILE) add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LARGE_FILES) diff --git a/src/gui/curses/CMakeLists.txt b/src/gui/curses/CMakeLists.txt index 910c38438..622d92d95 100644 --- a/src/gui/curses/CMakeLists.txt +++ b/src/gui/curses/CMakeLists.txt @@ -53,11 +53,6 @@ if(ENABLE_ZSTD) list(APPEND EXTRA_LIBS ${LIBZSTD_LDFLAGS}) endif() -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # link with resolv lib on macOS - list(APPEND EXTRA_LIBS "resolv") -endif() - if(ENABLE_NCURSES) subdirs(normal) endif()