Skip to content

Commit d4d3139

Browse files
hanidamlajfacebook-github-bot
authored andcommitted
use find_package(c-ares) instead of FindCares.cmake
Summary: clearly made a mistake here, lack of cmake experience (thanks mingtaoy): c-ares ships a CMake package (c-ares-config.cmake) that we should use instead of our bespoke FindCares.cmake Reviewed By: afrind Differential Revision: D81248145 fbshipit-source-id: 15b5595bac25f08dcf5faa7c3fb2efb10da3fc7b
1 parent ea5c4a4 commit d4d3139

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
find_path(CARES_INCLUDE_DIR NAMES ares.h)
8+
find_library(CARES_LIBRARIES NAMES cares)
9+
10+
include(FindPackageHandleStandardArgs)
11+
find_package_handle_standard_args(Cares DEFAULT_MSG CARES_LIBRARIES CARES_INCLUDE_DIR)
12+
13+
mark_as_advanced(
14+
CARES_LIBRARIES
15+
CARES_INCLUDE_DIR
16+
)
17+
18+
if(NOT TARGET cares)
19+
if("${CARES_LIBRARIES}" MATCHES ".*.a$")
20+
add_library(cares STATIC IMPORTED)
21+
else()
22+
add_library(cares SHARED IMPORTED)
23+
endif()
24+
set_target_properties(
25+
cares
26+
PROPERTIES
27+
IMPORTED_LOCATION ${CARES_LIBRARIES}
28+
INTERFACE_INCLUDE_DIRECTORIES ${CARES_INCLUDE_DIR}
29+
)
30+
endif()

0 commit comments

Comments
 (0)