未验证 提交 0aca659b 编写于 作者: G gouzil 提交者: GitHub

[cmake] fix Cache (#54764)

上级 f1c8d3fa
...@@ -15,21 +15,20 @@ ...@@ -15,21 +15,20 @@
include(ExternalProject) include(ExternalProject)
set(LIBMCT_PROJECT "extern_libmct") set(LIBMCT_PROJECT "extern_libmct")
if((NOT DEFINED LIBMCT_VER) OR (NOT DEFINED LIBMCT_URL)) set(LIBMCT_VER
message(STATUS "use pre defined download url") "0.1.0"
set(LIBMCT_VER CACHE STRING "" FORCE)
"0.1.0" set(LIBMCT_NAME
CACHE STRING "" FORCE) "libmct"
set(LIBMCT_NAME CACHE STRING "" FORCE)
"libmct" set(LIBMCT_DOWNLOAD_FILE
CACHE STRING "" FORCE) "${LIBMCT_NAME}.tar.gz"
set(LIBMCT_DOWNLOAD_FILE CACHE STRING "" FORCE)
"${LIBMCT_NAME}.tar.gz" set(LIBMCT_URL
CACHE STRING "" FORCE) "https://pslib.bj.bcebos.com/libmct/${LIBMCT_DOWNLOAD_FILE}"
set(LIBMCT_URL CACHE STRING "" FORCE)
"https://pslib.bj.bcebos.com/libmct/${LIBMCT_DOWNLOAD_FILE}" set(LIBMCT_URL_MD5 7e6b6c91b45b7490186f7120ef7e08fe)
CACHE STRING "" FORCE)
endif()
message(STATUS "LIBMCT_NAME: ${LIBMCT_NAME}, LIBMCT_URL: ${LIBMCT_URL}") message(STATUS "LIBMCT_NAME: ${LIBMCT_NAME}, LIBMCT_URL: ${LIBMCT_URL}")
set(LIBMCT_PREFIX_DIR "${THIRD_PARTY_PATH}/libmct") set(LIBMCT_PREFIX_DIR "${THIRD_PARTY_PATH}/libmct")
set(LIBMCT_DOWNLOAD_DIR set(LIBMCT_DOWNLOAD_DIR
...@@ -43,10 +42,39 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${LIBMCT_ROOT}/lib") ...@@ -43,10 +42,39 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${LIBMCT_ROOT}/lib")
include_directories(${LIBMCT_INC_DIR}) include_directories(${LIBMCT_INC_DIR})
file( function(download_libmct)
DOWNLOAD ${LIBMCT_URL} ${LIBMCT_DOWNLOAD_DIR}/${LIBMCT_DOWNLOAD_FILE} message(
TLS_VERIFY OFF STATUS
STATUS ERR) "Downloading ${LIBMCT_URL} to ${LIBMCT_DOWNLOAD_DIR}/${LIBMCT_DOWNLOAD_FILE}"
)
# NOTE: If the version is updated, consider emptying the folder; maybe add timeout
file(
DOWNLOAD ${LIBMCT_URL} ${LIBMCT_DOWNLOAD_DIR}/${LIBMCT_DOWNLOAD_FILE}
EXPECTED_MD5 ${LIBMCT_URL_MD5}
TLS_VERIFY OFF
STATUS ERR)
if(ERR EQUAL 0)
message(STATUS "Download ${LIBMCT_DOWNLOAD_FILE} success")
else()
message(
FATAL_ERROR
"Download failed, error: ${ERR}\n You can try downloading ${LIBMCT_DOWNLOAD_FILE} again"
)
endif()
endfunction()
# Download and check libmct.
if(EXISTS ${LIBMCT_DOWNLOAD_DIR}/${LIBMCT_DOWNLOAD_FILE})
file(MD5 ${LIBMCT_DOWNLOAD_DIR}/${LIBMCT_DOWNLOAD_FILE} LIBMCT_MD5)
if(NOT LIBMCT_MD5 STREQUAL LIBMCT_URL_MD5)
# clean build file
file(REMOVE_RECURSE ${LIBMCT_PREFIX_DIR})
file(REMOVE_RECURSE ${LIBMCT_INSTALL_DIR})
download_libmct()
endif()
else()
download_libmct()
endif()
file( file(
WRITE ${LIBMCT_DOWNLOAD_DIR}/CMakeLists.txt WRITE ${LIBMCT_DOWNLOAD_DIR}/CMakeLists.txt
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册