From e939236e810f37f4324fc6a7cc43188a2b7cc186 Mon Sep 17 00:00:00 2001 From: Zhou Wei <52485244+zhouwei25@users.noreply.github.com> Date: Tue, 1 Jun 2021 14:37:40 +0800 Subject: [PATCH] Fix duplicate download when incremental compilation (#33230) --- cmake/external/boost.cmake | 1 + cmake/external/mkldnn.cmake | 2 +- cmake/external/mklml.cmake | 3 +++ cmake/third_party.cmake | 9 +++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/external/boost.cmake b/cmake/external/boost.cmake index f14195480b7..d88d693d828 100644 --- a/cmake/external/boost.cmake +++ b/cmake/external/boost.cmake @@ -46,6 +46,7 @@ ExternalProject_Add( ${BOOST_PROJECT} ${EXTERNAL_PROJECT_LOG_ARGS} "${BOOST_DOWNLOAD_CMD}" + URL_MD5 f891e8c2c9424f0565f0129ad9ab4aff PREFIX ${BOOST_PREFIX_DIR} DOWNLOAD_DIR ${BOOST_SOURCE_DIR} SOURCE_DIR ${BOOST_SOURCE_DIR} diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake index 5ea03e6ea48..ce5603b24b6 100644 --- a/cmake/external/mkldnn.cmake +++ b/cmake/external/mkldnn.cmake @@ -110,7 +110,7 @@ if(WIN32) add_custom_command(TARGET ${MKLDNN_PROJECT} POST_BUILD VERBATIM COMMAND echo EXPORTS >> ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def) add_custom_command(TARGET ${MKLDNN_PROJECT} POST_BUILD VERBATIM - COMMAND echo off &&(for /f "skip=19 tokens=4" %A in (${MKLDNN_INSTALL_DIR}/bin/exports.txt) do echo %A >> ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def)&& echo on) + COMMAND echo off && (for /f "skip=19 tokens=4" %A in (${MKLDNN_INSTALL_DIR}/bin/exports.txt) do echo %A >> ${MKLDNN_INSTALL_DIR}/bin/mkldnn.def) && echo on) add_custom_command(TARGET ${MKLDNN_PROJECT} POST_BUILD VERBATIM COMMAND lib /def:${MKLDNN_INSTALL_DIR}/bin/mkldnn.def /out:${MKLDNN_INSTALL_DIR}/bin/mkldnn.lib /machine:x64) else(WIN32) diff --git a/cmake/external/mklml.cmake b/cmake/external/mklml.cmake index 4cf9b626d15..d99cb195295 100644 --- a/cmake/external/mklml.cmake +++ b/cmake/external/mklml.cmake @@ -24,6 +24,7 @@ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${MKLML_ROOT}/lib") IF(WIN32) SET(MKLML_VER "mklml_win_2019.0.5.20190502" CACHE STRING "" FORCE) SET(MKLML_URL "https://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.zip" CACHE STRING "" FORCE) + SET(MKLML_URL_MD5 ff8c5237570f03eea37377ccfc95a08a) SET(MKLML_LIB ${MKLML_LIB_DIR}/mklml.lib) SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.lib) SET(MKLML_SHARED_LIB ${MKLML_LIB_DIR}/mklml.dll) @@ -33,6 +34,7 @@ ELSE() # Now enable csrmm function in mklml library temporarily, it will be updated as offical version later. SET(MKLML_VER "csrmm_mklml_lnx_2019.0.5" CACHE STRING "" FORCE) SET(MKLML_URL "http://paddlepaddledeps.bj.bcebos.com/${MKLML_VER}.tgz" CACHE STRING "" FORCE) + SET(MKLML_URL_MD5 bc6a7faea6a2a9ad31752386f3ae87da) SET(MKLML_LIB ${MKLML_LIB_DIR}/libmklml_intel.so) SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5.so) SET(MKLML_SHARED_LIB ${MKLML_LIB_DIR}/libmklml_intel.so) @@ -52,6 +54,7 @@ ExternalProject_Add( ${MKLML_PROJECT} ${EXTERNAL_PROJECT_LOG_ARGS} "${MKLML_DOWNLOAD_CMD}" + URL_MD5 ${MKLML_URL_MD5} PREFIX ${MKLML_PREFIX_DIR} DOWNLOAD_DIR ${MKLML_SOURCE_DIR} SOURCE_DIR ${MKLML_SOURCE_DIR} diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 2ae4518c9df..d33edef38ca 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -108,13 +108,18 @@ ENDMACRO() # 2. NAME: The name of file, that determin the dirname # FUNCTION(file_download_and_uncompress URL NAME) - MESSAGE(STATUS "Download dependence[${NAME}] from ${URL}") + set(options "") + set(oneValueArgs MD5) + set(multiValueArgs "") + cmake_parse_arguments(URL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + MESSAGE(STATUS "Download dependence[${NAME}] from ${URL}, MD5: ${URL_MD5}") SET(${NAME}_INCLUDE_DIR ${THIRD_PARTY_PATH}/${NAME}/data PARENT_SCOPE) ExternalProject_Add( download_${NAME} ${EXTERNAL_PROJECT_LOG_ARGS} PREFIX ${THIRD_PARTY_PATH}/${NAME} URL ${URL} + URL_MD5 ${URL_MD5} TIMEOUT 120 DOWNLOAD_DIR ${THIRD_PARTY_PATH}/${NAME}/data/ SOURCE_DIR ${THIRD_PARTY_PATH}/${NAME}/data/ @@ -244,7 +249,7 @@ if(WITH_GPU) list(APPEND third_party_deps extern_cub) endif() set(URL "https://paddlepaddledeps.bj.bcebos.com/externalErrorMsg.tar.gz" CACHE STRING "" FORCE) - file_download_and_uncompress(${URL} "externalError") # download file externalErrorMsg.tar.gz + file_download_and_uncompress(${URL} "externalError" MD5 c0749523ebb536eb7382487d645d9cd4) # download file externalErrorMsg.tar.gz if(WITH_TESTING) # copy externalErrorMsg.pb for unittest 'enforce_test' set(SRC_DIR ${THIRD_PARTY_PATH}/externalError/data) -- GitLab