From a9d3cef942ebfb09e722199cbc882d5abeb54154 Mon Sep 17 00:00:00 2001 From: Zhenghai Zhang <65210872+ccsuzzh@users.noreply.github.com> Date: Thu, 10 Aug 2023 20:31:07 +0800 Subject: [PATCH] [cmake] add isl third_party cache (#55631) * add isl third_party cache * fix bug * Update cinn.cmake --- cmake/cinn.cmake | 2 +- cmake/cinn/external/isl.cmake | 55 +++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/cmake/cinn.cmake b/cmake/cinn.cmake index e2ab8c6c5c9..ff3731f3805 100644 --- a/cmake/cinn.cmake +++ b/cmake/cinn.cmake @@ -331,7 +331,7 @@ set(ABSL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/dist/third_party/absl/include") include_directories(${ABSL_INCLUDE_DIR}) # Add isl -set(ISL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/dist/third_party/isl/include") +set(ISL_INCLUDE_DIR "${CMAKE_BINARY_DIR}/third_party/install/isl/include") include_directories(${ISL_INCLUDE_DIR}) # Add LLVM diff --git a/cmake/cinn/external/isl.cmake b/cmake/cinn/external/isl.cmake index da957c6f632..6c05e425b48 100644 --- a/cmake/cinn/external/isl.cmake +++ b/cmake/cinn/external/isl.cmake @@ -7,25 +7,62 @@ include(ExternalProject) # static build # CPPFLAGS="-fPIC -DPIC" ./configure --with-gmp-prefix= --with-clang-prefix= --enable-shared=no --enable-static=yes +set(ISL_FILE + "isl-6a1760fe.tar.gz" + CACHE STRING "" FORCE) set(ISL_DOWNLOAD_URL - https://paddle-inference-dist.bj.bcebos.com/CINN/isl-6a1760fe.tar.gz) -set(ISL_MD5 fff10083fb79d394b8a7b7b2089f6183) + "https://paddle-inference-dist.bj.bcebos.com/CINN/${ISL_FILE}") +set(ISL_URL_MD5 fff10083fb79d394b8a7b7b2089f6183) +set(ISL_DOWNLOAD_DIR ${PADDLE_SOURCE_DIR}/third_party/isl) +set(ISL_PREFIX_DIR ${THIRD_PARTY_PATH}/isl) +set(ISL_INSTALL_DIR ${THIRD_PARTY_PATH}/install/isl) + +function(download_isl) + message( + STATUS "Downloading ${ISL_DOWNLOAD_URL} to ${ISL_DOWNLOAD_DIR}/${ISL_FILE}") + file( + DOWNLOAD ${ISL_DOWNLOAD_URL} ${ISL_DOWNLOAD_DIR}/${ISL_FILE} + EXPECTED_MD5 ${ISL_URL_MD5} + STATUS ERR) + if(ERR EQUAL 0) + message(STATUS "Download ${ISL_FILE} success") + else() + message( + FATAL_ERROR + "Download failed, error: ${ERR}\n You can try downloading ${ISL_FILE} again" + ) + endif() +endfunction() + +# Download and check isl. +if(EXISTS ${ISL_DOWNLOAD_DIR}/${ISL_FILE}) + file(MD5 ${ISL_DOWNLOAD_DIR}/${ISL_FILE} ISL_MD5) + if(NOT ISL_MD5 STREQUAL ISL_URL_MD5) + # clean build file + file(REMOVE_RECURSE ${ISL_PREFIX_DIR}) + file(REMOVE_RECURSE ${ISL_INSTALL_DIR}) + download_isl() + endif() +else() + download_isl() +endif() ExternalProject_Add( external_isl ${EXTERNAL_PROJECT_LOG_ARGS} - URL ${ISL_DOWNLOAD_URL} - URL_MD5 ${ISL_MD5} - PREFIX ${THIRD_PARTY_PATH}/isl - SOURCE_DIR ${THIRD_PARTY_PATH}/install/isl + URL ${ISL_DOWNLOAD_DIR}/${ISL_FILE} + URL_MD5 ${ISL_URL_MD5} + DOWNLOAD_DIR ${ISL_DOWNLOAD_DIR} + PREFIX ${ISL_PREFIX_DIR} + SOURCE_DIR ${ISL_INSTALL_DIR} CONFIGURE_COMMAND "" BUILD_COMMAND "" UPDATE_COMMAND "" INSTALL_COMMAND "" - BUILD_BYPRODUCTS ${THIRD_PARTY_PATH}/install/isl/lib/libisl.a) + BUILD_BYPRODUCTS ${ISL_INSTALL_DIR}/lib/libisl.a) add_library(isl STATIC IMPORTED GLOBAL) set_property(TARGET isl PROPERTY IMPORTED_LOCATION - ${THIRD_PARTY_PATH}/install/isl/lib/libisl.a) + ${ISL_INSTALL_DIR}/lib/libisl.a) add_dependencies(isl external_isl) -include_directories(${THIRD_PARTY_PATH}/install/isl/include) +include_directories(${ISL_INSTALL_DIR}/include) -- GitLab