ceph/cmake/modules/Buildc-ares.cmake
Kefu Chai 3121de1c70 cmake: s/c-ares::c-ares/c-ares::cares/
to be aligned with the c-ares upstream, which provides
c-ares-config.cmake in c-ares v1.17 and up. this cmake config file
is also packaged by fedora and CentOS stream in c-ares-devel-1.17.1 and
up.

this change prepares us for bumping up Seastar submodule, which also
has a similar change: aea45c98f2

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2022-11-22 01:17:30 +08:00

25 lines
952 B
CMake

function(build_c_ares)
include(ExternalProject)
set(C-ARES_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/c-ares")
set(C-ARES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/c-ares")
ExternalProject_Add(c-ares_ext
SOURCE_DIR "${C-ARES_SOURCE_DIR}"
CMAKE_ARGS
-DCARES_STATIC=ON
-DCARES_SHARED=OFF
-DCARES_INSTALL=OFF
BINARY_DIR "${C-ARES_BINARY_DIR}"
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR>
INSTALL_COMMAND "")
add_library(c-ares::cares STATIC IMPORTED)
add_dependencies(c-ares::cares c-ares_ext)
set_target_properties(c-ares::cares PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${C-ARES_SOURCE_DIR};${C-ARES_BINARY_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${C-ARES_BINARY_DIR}/lib/libcares.a")
# to appease find_package()
add_custom_target(c-ares DEPENDS c-ares::cares)
# to be compatible with old Seastar
add_library(c-ares::c-ares ALIAS c-ares::cares)
endfunction()