Files
shadowsocks-libev/cmake/FindCares.cmake
Max Lv 201e70c4bd Modernize C builds with offline dependencies and portable runtime helpers (#3050)
Bundle pinned offline dependencies, remove libcork/libipset and submodule requirements, and add portable runtime helpers with relocatable static/shared library installations.

Add Clang static build validation for Linux/musl, macOS and Windows, real TCP/UDP and SIP003 interoperability coverage, and recorded performance tradeoffs. All 21 hosted checks pass at the reviewed PR head 8d504e6218.
2026-09-11 13:42:11 +08:00

48 lines
1.2 KiB
CMake

# FindCares.cmake - Find c-ares library
#
# Sets:
# CARES_FOUND
# CARES_INCLUDE_DIRS
# CARES_LIBRARIES
find_path(CARES_INCLUDE_DIR
NAMES ares.h
HINTS
/opt/homebrew/include
/usr/local/include
/opt/homebrew/opt/c-ares/include
/usr/local/opt/c-ares/include
/usr/include
)
find_library(CARES_LIBRARY
NAMES cares
HINTS
/opt/homebrew/lib
/usr/local/lib
/opt/homebrew/opt/c-ares/lib
/usr/local/opt/c-ares/lib
/usr/lib
)
if(CARES_INCLUDE_DIR AND CARES_LIBRARY)
set(CARES_FOUND TRUE)
set(CARES_INCLUDE_DIRS ${CARES_INCLUDE_DIR})
set(CARES_LIBRARIES ${CARES_LIBRARY})
# Verify ares_library_init exists
include(CheckLibraryExists)
check_library_exists(cares ares_library_init "" CARES_HAS_INIT)
if(NOT CARES_HAS_INIT)
message(WARNING "c-ares found but ares_library_init not detected. Proceeding anyway.")
endif()
message(STATUS "Found c-ares: ${CARES_LIBRARY}")
else()
set(CARES_FOUND FALSE)
message(FATAL_ERROR "Could not find c-ares library. Install libc-ares-dev or equivalent.")
endif()
# CMake find_dependency uses the exact package-name spelling.
set(Cares_FOUND ${CARES_FOUND})