mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
cmake: build c-ares if it's not found or not new enough
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
e6f053d6b6
commit
4e61f2286d
22
cmake/modules/Buildc-ares.cmake
Normal file
22
cmake/modules/Buildc-ares.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
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::c-ares STATIC IMPORTED)
|
||||
add_dependencies(c-ares::c-ares c-ares_ext)
|
||||
set_target_properties(c-ares::c-ares PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${C-ARES_SOURCE_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::c-ares)
|
||||
endfunction()
|
31
cmake/modules/Findc-ares.cmake
Normal file
31
cmake/modules/Findc-ares.cmake
Normal file
@ -0,0 +1,31 @@
|
||||
find_package(PkgConfig)
|
||||
|
||||
pkg_search_module(PC_cares
|
||||
libcares)
|
||||
|
||||
find_path(c-ares_INCLUDE_DIR
|
||||
NAMES ares_dns.h
|
||||
PATHS ${PC_cares_INCLUDE_DIRS})
|
||||
|
||||
find_library(c-ares_LIBRARY
|
||||
NAMES cares
|
||||
PATHS ${PC_cares_LIBRARY_DIRS})
|
||||
|
||||
set(c-ares_VERSION ${PC_cares_VERSION})
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(c-ares
|
||||
FOUND_VAR c-ares_FOUND
|
||||
REQUIRED_VARS
|
||||
c-ares_INCLUDE_DIR
|
||||
c-ares_LIBRARY
|
||||
VERSION_VAR c-ares_VERSION)
|
||||
|
||||
if(c-ares_FOUND AND NOT (TARGET c-ares::c-ares))
|
||||
add_library(c-ares::c-ares UNKNOWN IMPORTED)
|
||||
set_target_properties(c-ares::c-ares PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${c-ares_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${c-ares_LIBRARY}")
|
||||
endif()
|
@ -384,10 +384,15 @@ include_directories("${CMAKE_SOURCE_DIR}/src/dmclock/support/src")
|
||||
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/googletest/googletest/include")
|
||||
|
||||
if(WITH_SEASTAR)
|
||||
find_package(fmt CONFIG QUIET)
|
||||
find_package(fmt QUIET CONFIG)
|
||||
if(NOT fmt_FOUND)
|
||||
add_subdirectory(fmt)
|
||||
endif()
|
||||
find_package(c-ares 1.13.0 QUIET MODULE)
|
||||
if(NOT c-ares_FOUND)
|
||||
include(Buildc-ares)
|
||||
build_c_ares()
|
||||
endif()
|
||||
macro(find_package name)
|
||||
if(NOT TARGET ${name})
|
||||
_find_package(${ARGV})
|
||||
|
Loading…
Reference in New Issue
Block a user