1
- # build and install c-ares
2
- macro (build_install_cares )
1
+ # add c-ares
2
+ macro (add_cares )
3
3
if (NOT c-ares_DOWNLOAD_URL )
4
4
get_github_latest_release_url ("c-ares" "c-ares" )
5
5
endif ()
6
6
FetchContent_Declare (c-ares URL ${c-ares_DOWNLOAD_URL} )
7
- # not using FetchContent_MakeAvailable to save compile time
8
- FetchContent_GetProperties (c-ares )
9
-
10
- if (NOT c-ares_POPULATED )
11
- FetchContent_Populate (c-ares )
12
-
13
- # configure build and install
14
- if (CMAKE_CXX_COMPILER_ID MATCHES MSVC )
15
- execute_process (
16
- COMMAND cmake -B ${c-ares_BINARY_DIR} -S ${c-ares_SOURCE_DIR} --fresh -DCARES_BUILD_TOOLS=OFF
17
- -DCMAKE_INSTALL_PREFIX=${C-ARES_ROOT_DIR}
18
- )
19
- execute_process (COMMAND cmake --build ${c-ares_BINARY_DIR} --config Release )
20
- execute_process (COMMAND cmake --install ${c-ares_BINARY_DIR} --config Release )
21
- execute_process (COMMAND cmake --build ${c-ares_BINARY_DIR} --config Debug )
22
- execute_process (COMMAND cmake --install ${c-ares_BINARY_DIR} --config Debug )
23
- else ()
24
- execute_process (
25
- COMMAND cmake -B ${c-ares_BINARY_DIR} -S ${c-ares_SOURCE_DIR} --fresh -DCARES_BUILD_TOOLS=OFF
26
- -DCMAKE_INSTALL_PREFIX=${C-ARES_ROOT_DIR}
27
- )
28
- execute_process (COMMAND cmake --build ${c-ares_BINARY_DIR} )
29
- execute_process (COMMAND cmake --install ${c-ares_BINARY_DIR} )
30
- endif ()
31
-
32
- endif ()
7
+ FetchContent_MakeAvailable (c-ares )
33
8
endmacro ()
34
9
35
10
# Set normal resolver
@@ -55,27 +30,12 @@ macro(set_cares_resolver)
55
30
list (APPEND TRANTOR_SOURCES trantor/net/inner/AresResolver.cc )
56
31
list (APPEND private_headers trantor/net/inner/AresResolver.h )
57
32
58
- # copy dll/libs for Windows, to solve the test/unittests running 0x000135 error
59
- copy_files_for_win (${C-ARES_ROOT_DIR}/bin "dll" )
60
- copy_files_for_win (${C-ARES_ROOT_DIR}/lib "lib" )
61
33
endmacro ()
62
34
63
35
# ######################################################################################################################
64
36
message (STATUS "Setting c-ares: ${TRANTOR_USE_C-ARES}" )
65
37
66
38
if (TRANTOR_USE_C-ARES )
67
- # Set C-ARES_ROOT_DIR, to let find_package could search from it
68
- if (WIN32 )
69
- set (C-ARES_ROOT_DIR
70
- ${CMAKE_INSTALL_PREFIX} /../c-ares
71
- CACHE PATH "Let find_package use the directory to find" FORCE
72
- )
73
- else ()
74
- set (C-ARES_ROOT_DIR
75
- ${CMAKE_INSTALL_PREFIX} /c-ares
76
- CACHE PATH "Let find_package use the directory to find" FORCE
77
- )
78
- endif ()
79
39
80
40
find_package (c-ares )
81
41
@@ -84,8 +44,7 @@ if(TRANTOR_USE_C-ARES)
84
44
message (STATUS "⚠️c-ares not found, Building it with FetchContent..." )
85
45
unset (c-ares_FOUND )
86
46
87
- build_install_cares ()
88
- find_package (c-ares REQUIRED )
47
+ add_cares ()
89
48
90
49
else ()
91
50
message (FATAL_ERROR "⛔c-ares not found, please install it or set FETCH_BUILD_MISSING_DEPS to ON" )
0 commit comments