未验证 提交 74eb3093 编写于 作者: 张春乔 提交者: GitHub

[cmake] add ginac third_party cache (#56165)

* Update ginac.cmake

* Update ginac.cmake

* Update ginac.cmake
上级 8cf4b1c2
...@@ -5,32 +5,68 @@ include(ExternalProject) ...@@ -5,32 +5,68 @@ include(ExternalProject)
# ginac-1.8.1 https://www.ginac.de/ginac-1.8.1.tar.bz2 # ginac-1.8.1 https://www.ginac.de/ginac-1.8.1.tar.bz2
# all build with CFLAGS="-fPIC -DPIC" CXXFLAGS="-fPIC -DPIC" --enable-static=yes # all build with CFLAGS="-fPIC -DPIC" CXXFLAGS="-fPIC -DPIC" --enable-static=yes
set(GINAC_FILE
"ginac-1.8.1_cln-1.3.6_gmp-6.2.1.tar.gz"
CACHE STRING "" FORCE)
set(GINAC_DOWNLOAD_URL set(GINAC_DOWNLOAD_URL
https://paddle-inference-dist.bj.bcebos.com/CINN/ginac-1.8.1_cln-1.3.6_gmp-6.2.1.tar.gz "https://paddle-inference-dist.bj.bcebos.com/CINN/${GINAC_FILE}")
) set(GINAC_URL_MD5 ebc3e4b7770dd604777ac3f01bfc8b06)
set(GINAC_MD5 ebc3e4b7770dd604777ac3f01bfc8b06) set(GINAC_DOWNLOAD_DIR ${PADDLE_SOURCE_DIR}/third_party/ginac)
set(GINAC_PREFIX_DIR ${THIRD_PARTY_PATH}/ginac)
set(GINAC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/ginac)
function(download_ginac)
message(
STATUS
"Downloading ${GINAC_DOWNLOAD_URL} to ${GINAC_DOWNLOAD_DIR}/${GINAC_FILE}"
)
file(
DOWNLOAD ${GINAC_DOWNLOAD_URL} ${GINAC_DOWNLOAD_DIR}/${GINAC_FILE}
EXPECTED_MD5 ${GINAC_URL_MD5}
STATUS ERR)
if(ERR EQUAL 0)
message(STATUS "Download ${GINAC_FILE} success")
else()
message(
FATAL_ERROR
"Download failed, error: ${ERR}\n You can try downloading ${GINAC_FILE} again"
)
endif()
endfunction()
# Download and check ginac.
if(EXISTS ${GINAC_DOWNLOAD_DIR}/${GINAC_FILE})
file(MD5 ${GINAC_DOWNLOAD_DIR}/${GINAC_FILE} GINAC_MD5)
if(NOT GINAC_MD5 STREQUAL GINAC_URL_MD5)
# clean build file
file(REMOVE_RECURSE ${GINAC_PREFIX_DIR})
file(REMOVE_RECURSE ${GINAC_INSTALL_DIR})
download_ginac()
endif()
else()
download_ginac()
endif()
ExternalProject_Add( ExternalProject_Add(
external_ginac external_ginac
${EXTERNAL_PROJECT_LOG_ARGS} ${EXTERNAL_PROJECT_LOG_ARGS}
URL ${GINAC_DOWNLOAD_URL} URL ${GINAC_DOWNLOAD_DIR}/${GINAC_FILE}
URL_MD5 ${GINAC_MD5} URL_MD5 ${GINAC_URL_MD5}
PREFIX ${THIRD_PARTY_PATH}/ginac DOWNLOAD_DIR ${GINAC_DOWNLOAD_DIR}
SOURCE_DIR ${THIRD_PARTY_PATH}/install/ginac PREFIX ${GINAC_PREFIX_DIR}
SOURCE_DIR ${GINAC_INSTALL_DIR}
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
UPDATE_COMMAND "" UPDATE_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${THIRD_PARTY_PATH}/install/ginac/lib/libginac.a BUILD_BYPRODUCTS ${GINAC_INSTALL_DIR}/lib/libginac.a
BUILD_BYPRODUCTS ${THIRD_PARTY_PATH}/install/ginac/lib/libcln.a BUILD_BYPRODUCTS ${GINAC_INSTALL_DIR}/lib/libcln.a
BUILD_BYPRODUCTS ${THIRD_PARTY_PATH}/install/ginac/lib/libgmp.a) BUILD_BYPRODUCTS ${GINAC_INSTALL_DIR}/lib/libgmp.a)
add_library(ginac STATIC IMPORTED GLOBAL) add_library(ginac STATIC IMPORTED GLOBAL)
add_dependencies(ginac external_ginac) add_dependencies(ginac external_ginac)
set_property( set_property(TARGET ginac PROPERTY IMPORTED_LOCATION
TARGET ginac PROPERTY IMPORTED_LOCATION ${GINAC_INSTALL_DIR}/lib/libginac.a)
${THIRD_PARTY_PATH}/install/ginac/lib/libginac.a) target_link_libraries(ginac INTERFACE ${GINAC_INSTALL_DIR}/lib/libcln.a
target_link_libraries( ${GINAC_INSTALL_DIR}/lib/libgmp.a)
ginac INTERFACE ${THIRD_PARTY_PATH}/install/ginac/lib/libcln.a include_directories(${GINAC_INSTALL_DIR}/include)
${THIRD_PARTY_PATH}/install/ginac/lib/libgmp.a)
include_directories(${THIRD_PARTY_PATH}/install/ginac/include)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册