Skip to content

Commit

Permalink
为GitHub流程调整cmake库的下载地址
Browse files Browse the repository at this point in the history
cmake 附带 GitHubActions 宏时 使用非代理地址构建cmake
  • Loading branch information
cngege committed Jun 2, 2024
1 parent 771cae0 commit a3f1c64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: chcp 65001 && cmake -B ${{github.workspace}}/build
run: chcp 65001 && cmake -B ${{github.workspace}}/build -DGitHubActions=1

- name: Build
# Build your program with the given configuration
Expand Down
27 changes: 18 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ include(FetchContent)
include_directories(include)
include_directories(Utils)

if(DEFINED GitHubActions)
set(CLI11_URL https://github.com/CLIUtils/CLI11.git)
set(LIBSSL_URL https://github.com/cngege/cngege.github.io/releases/download/v0.1-beta.1/libssl.lib)
set(CRYPTO_URL https://github.com/cngege/cngege.github.io/releases/download/v0.1-beta.1/libcrypto.lib)
else()
set(CLI11_URL https://gitclone.com/github.com/CLIUtils/CLI11.git)
set(LIBSSL_URL https://gh.ddlc.top/https://github.com/cngege/cngege.github.io/releases/download/v0.1-beta.1/libssl.lib)
set(CRYPTO_URL https://gh.ddlc.top/https://github.com/cngege/cngege.github.io/releases/download/v0.1-beta.1/libcrypto.lib)
endif()



Expand All @@ -40,19 +49,19 @@ endif()
# /////////////////////////////////////ssl库lib名称////////////////////////////////////////////////
SET(OPENSSL_SSL_NAME "libssl.lib")
# ssl远程下载地址
SET(SSL_DOWNLOAD_URL "https://gh.ddlc.top/https://github.com/cngege/cngege.github.io/releases/download/v0.1-beta.1/libssl.lib")
SET(SSL_DOWNLOAD_URL ${LIBSSL_URL})
MESSAGE(STATUS "Checking ${OPENSSL_SSL_NAME}...")
# 判断库文件是否已经存在
FIND_FILE(LOCAL_OPENSSL_SSL_LIB
NAMES ${OPENSSL_SSL_NAME}
HINTS "${PROJECT_SOURCE_DIR}/openssl-proj/lib"
NO_DEFAULT_PATH)
MESSAGE(STATUS "Checking url link ${SSL_DOWNLOAD_URL} ...")
MESSAGE(STATUS "Checking url link ${LIBSSL_URL} ...")
# 如果路径下没有目标文件
IF(NOT LOCAL_OPENSSL_SSL_LIB)
MESSAGE(STATUS "Downloading ${OPENSSL_SSL_NAME} to ${LOCAL_OPENSSL_LIBRARIES_PATH} ...")
# 从设定的 URL 地址下载相应的压缩包
FILE(DOWNLOAD ${SSL_DOWNLOAD_URL}
FILE(DOWNLOAD ${LIBSSL_URL}
${LOCAL_OPENSSL_LIBRARIES_PATH}/${OPENSSL_SSL_NAME}
TIMEOUT ${DOWNLOAD_OPENSSL_TIMEOUT}
STATUS ERR
Expand All @@ -66,7 +75,7 @@ IF(NOT LOCAL_OPENSSL_SSL_LIB)
FILE(REMOVE ${LOCAL_OPENSSL_LIBRARIES_PATH}/${OPENSSL_SSL_NAME})
MESSAGE(STATUS "Download failed, error: ${ERR}")
MESSAGE(FATAL_ERROR
"You can try downloading ${SSL_DOWNLOAD_URL} manually"
"You can try downloading ${LIBSSL_URL} manually"
"using curl/wget or a similar tool")
ENDIF()
ENDIF()
Expand All @@ -79,19 +88,19 @@ ENDIF()
# /////////////////////////////////////crypto库lib名称////////////////////////////////////////////////
SET(OPENSSL_CRYPTO_NAME "libcrypto.lib")
# ssl远程下载地址
SET(CRYPTO_DOWNLOAD_URL "https://gh.ddlc.top/https://github.com/cngege/cngege.github.io/releases/download/v0.1-beta.1/libcrypto.lib")
SET(CRYPTO_DOWNLOAD_URL ${CRYPTO_URL})
MESSAGE(STATUS "Checking ${OPENSSL_CRYPTO_NAME}...")
# 判断库文件是否已经存在
FIND_FILE(LOCAL_OPENSSL_CRYPTO_LIB
NAMES ${OPENSSL_CRYPTO_NAME}
HINTS "${PROJECT_SOURCE_DIR}/openssl-proj/lib"
NO_DEFAULT_PATH)
MESSAGE(STATUS "Checking url link ${CRYPTO_DOWNLOAD_URL} ...")
MESSAGE(STATUS "Checking url link ${CRYPTO_URL} ...")
# 如果路径下没有目标文件
IF(NOT LOCAL_OPENSSL_CRYPTO_LIB)
MESSAGE(STATUS "Downloading ${OPENSSL_CRYPTO_NAME} to ${LOCAL_OPENSSL_LIBRARIES_PATH} ...")
# 从设定的 URL 地址下载相应的压缩包
FILE(DOWNLOAD ${CRYPTO_DOWNLOAD_URL}
FILE(DOWNLOAD ${CRYPTO_URL}
${LOCAL_OPENSSL_LIBRARIES_PATH}/${OPENSSL_CRYPTO_NAME}
TIMEOUT ${DOWNLOAD_OPENSSL_TIMEOUT}
STATUS ERR
Expand All @@ -105,7 +114,7 @@ IF(NOT LOCAL_OPENSSL_CRYPTO_LIB)
FILE(REMOVE ${LOCAL_OPENSSL_LIBRARIES_PATH}/${OPENSSL_CRYPTO_NAME})
MESSAGE(STATUS "Download failed, error: ${ERR}")
MESSAGE(FATAL_ERROR
"You can try downloading ${CRYPTO_DOWNLOAD_URL} manually"
"You can try downloading ${CRYPTO_URL} manually"
"using curl/wget or a similar tool")
ENDIF()
ENDIF()
Expand All @@ -131,7 +140,7 @@ target_link_libraries(GitHubDesktop2Chinese PRIVATE
FetchContent_Declare(
cli11_proj
QUIET
GIT_REPOSITORY https://gitclone.com/github.com/CLIUtils/CLI11.git
GIT_REPOSITORY ${CLI11_URL}
GIT_TAG v2.4.1
)
FetchContent_MakeAvailable(cli11_proj)
Expand Down

0 comments on commit a3f1c64

Please sign in to comment.