Skip to content

Commit 7fe58a6

Browse files
committed
fix build bug
1 parent 7312683 commit 7fe58a6

File tree

2 files changed

+7
-49
lines changed

2 files changed

+7
-49
lines changed

.github/workflows/windows-msvc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,16 @@ jobs:
135135
submodules: false
136136

137137
# This step let nmake/ninja could work
138-
- name: Setup MSVC-DEV-CMD
139-
uses: ilammy/msvc-dev-cmd@v1
138+
- name: Setup MSVC-DEV-CMD
139+
uses: seanmiddleditch/gha-setup-vsdevenv@master
140140

141141
- uses: actions/cache@v4
142142
id: cmake-fetch-content-cache
143143
with:
144144
path: |
145-
C:/Program Files/c-ares
146145
C:/Program Files/Botan
147146
C:/Program Files/OpenSSL
148-
key: windows-cmake-fetch-content-${{matrix.build-type}}-${{matrix.tls-provider}}
147+
key: windows-fetch-${{matrix.build-type}}-${{matrix.tls-provider}}
149148

150149
- name: Configure Cmake
151150
# passing "-DFETCHCONTENT_BASE_DIR=D:/a/trantor/_deps" to keep cache

cmake/SetCAres.cmake

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,10 @@
1-
# build and install c-ares
2-
macro(build_install_cares)
1+
# add c-ares
2+
macro(add_cares)
33
if(NOT c-ares_DOWNLOAD_URL)
44
get_github_latest_release_url("c-ares" "c-ares")
55
endif()
66
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)
338
endmacro()
349

3510
# Set normal resolver
@@ -55,27 +30,12 @@ macro(set_cares_resolver)
5530
list(APPEND TRANTOR_SOURCES trantor/net/inner/AresResolver.cc)
5631
list(APPEND private_headers trantor/net/inner/AresResolver.h)
5732

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")
6133
endmacro()
6234

6335
# ######################################################################################################################
6436
message(STATUS "Setting c-ares: ${TRANTOR_USE_C-ARES}")
6537

6638
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()
7939

8040
find_package(c-ares)
8141

@@ -84,8 +44,7 @@ if(TRANTOR_USE_C-ARES)
8444
message(STATUS "⚠️c-ares not found, Building it with FetchContent...")
8545
unset(c-ares_FOUND)
8646

87-
build_install_cares()
88-
find_package(c-ares REQUIRED)
47+
add_cares()
8948

9049
else()
9150
message(FATAL_ERROR "⛔c-ares not found, please install it or set FETCH_BUILD_MISSING_DEPS to ON")

0 commit comments

Comments
 (0)